05 Managing Processes and Jobs

ps

 

ps -e everthing all process

ps -f full format listing

ps -u username  display username processes

ps -p PID display information for PID

 

ps -ef  display all processes, full

ps -eH display a process tree

ps -e –forest display a process tree

ps -ef | less

 

pstree

top

? for help

htop

 

command &  start command in background

Ctrl -c Kill the foreground process

Ctrl-z Suspend the foreground process

 

bg [%num]

fg [%num]

kill

jobs [%num]

 

 

kill -l 

kill -l

 

cron

crontab

crontab format

crontab format

 

# run every monday at 7 AM

0 7 * * 1 /opt/sales/bin/report

 

example crontab with wildcard

 

Redirecting Output

#run at 02:00 every day and send output to a log file

0 2 *** /root/backup > /tmp/db.log 2>&1

 

crontab example

 

Crontab Shortcuts

@yearly         0 0 1  1 *

@annually    0 0 1  1 *

@monthly    0 0  1 *  *  first day of the month

@weekly       0 0 *  * 0  midnight at morning od Sunday

@daily           0 0 *  *  * every day at mignight

@midnight   0 0 *  *  *

@hourly        0 *  * * * once at hour

 

 

crontab -l  list your cron

crontab -e edit

crontab -r remove alll of your crontab

 

set editor  vi

echo $EDITOR

EDITOR=vi

crontab -e