UNIX Process Management

Monitoring Process Progress

Pipe Viewer (pv)

Example

Cloning a disk...

dd if=/dev/sdb bs=512 conv=sync,noerror | pv | dd of=/dev/sdd

Installationapt install pvyum install pvdnf install pv

Progress (progress)

TODO

Finding Processes

Find MySQL processes...

pgrep mysql

or

pidof mysqld

Terminating Processes

To terminate process 4567...

kill 4567

To forcibly terminate process 4567...

kill -9 4567

kill -SIGKILL 4567

To kill Job #2 (from jobs output)...

kill %2

To kill all wget processes you could use...

pkill wget

(note that this can be dangerous)

Running Processes in the Background

See also: UNIX Scheduling and Screen

To start a script and run it in the background (i.e. you can continue to use the current shell whilst the process runs) use...

myscript.sh &

If you log out of your shell the process will terminate. To prevent this use...

nohup myscript.sh &

To see which jobs are running in your shell...

jobs

To see which processes are running in your session...

ps

To see all processes...

ps -ef

ps aux

To move a long running script (currently running in the foreground) to the background...

Ctrl-Z

bg

To bring it back to the foreground...

fg

If there is more than 1 job in the background, to move jobs 2 to the foreground...

fg %2

To set background job 2 to nohup so you can terminate your shell (bash)...

disown %2

To set all background jobs to nohup so you can terminate your shell (bash)...

disown -a

To set process 4567 (from ps) to nohup (AIX/Solaris)...

nohup -p 4567

Alternate method...

kill -SIGSTOP 4567

kill -SIGCONT 4567