Linux enables control over the execution of commands, jobs, or programs. A user can interrupt the command, or start it from where it lets off, run in the background for extended jobs, or cancel it.
Job Management Operations
$ jobs: Lists all background jobs running in background consisting of job number in the brackets. The jobs are in a state of processing, execution, or stopped. The + sign before the job indicates being processed and – shows next to be executed.
$ ps -a: List all currently running processes including background jobs. The ps command displays the PID (process ID), TTY (Terminal identifier), Time (how long process has taken so far), and name of the Command in process.
$ ps -ef provides a complete listing of running processes
$ ps -ejH indents related processes to make the relationship between processes visually more evident
$ ps -C <Command-name> -o pid=
displays the PID number of a particular command and to kill it
$ kill ‘ps -C <Command-name> -o pid='
The ps command options:
- -e select all processes
- -j use the jobs format
- -f provide a full format listing
- -H show the process hierarchy (i.e., the “forest format”)
- -x lift the “must be associated with a tty” restriction
at time date Execute commands at specified time and date. The time can be entered with hours and minutes and qualified as A.M or P.M
- % Reference recent job
- %jobnum Reference job by the job-number
- %string Reference job by an exact matching string
- $?string? Reference job that contains a unique string
- %– Reference job before a recent job
Bringing to Background
bg: Place the command into the background from foreground
Till the user command execute in the background, a user can continue executing other Linux commands.
& run the command in the background
Bringing to Foreground
fg %jobnum: bring a command in the foreground from a background or resume an interrupted program
Suspending or Stopping Jobs
^Z Interrupt and stop currently running program which then waits in the background for a resumption
notify %jobnum: Notifies when a job ends
kill %jobnum or kill %processnum: Cancel and ends a program