Jobs are processes linked with the shell process that can run in the foreground or background (or be paused). Bash provides various ways to manage jobs.
Managing jobs
- Use
&at the end of a command to run it in background, likeping & - Use
& disownat the end of a command to run it in the background and detach it from the current session (so that when the shell dies, it would still be running), like so:ping -c 100 &disown - Use Ctrl-Z to background and suspend a process
- Use
bgto have a suspended job continue running in the background. - Use
fgto have a background job return to the foreground. If the job is suspended, the job will automatically continue. - You can use
killon jobs too.
Referencing a job
You will need to refer to a specific job in the commands above if there are more than one job in the background.
- Use
jobsto list jobs under the current session. %num: refers by job number, e.g.kill %1%cmd: refers by the beginning of a job command such as%nmap%+or%%: current job%-: previous job