67. Process Management - &, bg, fg, jobs and nohup
Contents
With commands such as bg fg jobs, we can do something about jobs in the background.
&
Keep a command running in the background of the current session:
|
|
bg
Wake up the paused background processes in the current environment and continue running.
|
|
fg
Moves a background process from the current environment to the foreground.
|
|
jobs
Show the status of the background jobs in the current session.
Here are some options for jobs command:
Option | Description |
---|---|
-l | Show the job number, current job, process group number, status, and the command that make up the job. |
-p | Show the process group leader IDs of the jobs. |
|
|
nohup
Prepare an infinite loop script:
|
|
Keep the script running in the background, even if the user logs out of the system, the running state of the command will not be terminated.
|
|
Check for running jobs’ process IDs:
|
|
Kill the running process:
|
|
Double check the jobs:
|
|
References 7.2 Job Control Builtins, BG(1P), FG(1P), NOHUP(1), JOBS(1P)
Author Dong Chen
LastMod Mon Apr 8 2019