Linux Process Management
ps
- process listing command
An example of a good general purpose process listing including a long formatted date-time of the start time of the command and the elapsed time since the process was started.
ps -eo pid,lstart,etime,cmd:128
- List processes looking for specific process names.
- Use a regex with a character class so that the grep command itself doesn't appear in the output of the ps command.
ps -ef | grep -i "[f]oobar"
- List process hierarchy (tree)
ps -ejH
disown
- process termination
When a process is started from a bash shell the process is a child of the shell and when the terminal session ends the child will be sent a signal that will result in the process being terminated. To prevent this the bash disown -ha command can be used to cause the child process to not receive the signal. As a result the process will remaining running after the terminal session ends.
nohup
nohup
runs the specified program so that it will not receive a hang-up signal when the terminal exists. Therefore the program will continue running like a daemon.
nohup python /path/to/script.py &