jobs and ps (Display Jobs and Processes)
The jobs
command is used to check running jobs while the ps
command is used to check running processes.
Check running jobs – jobs
The jobs command shows the job ID, status of each job (running, stopped, done, terminated), and job name. There is also the + or - symbol after job numbers. + refers to the current job and - refers to the previous job.
jobs
[1] Running ./loop.sh > countdown_bg.txt &
[2]+ Stopped ./loop.sh > countdown_bg.txt
[3] Running ./loop.sh > countdown_bg.txt &
[4]- Running ./loop.sh > countdown_bg.txt &
-l option
If you want to show the process number, use the -l
option.
jobs -l
[1] 85945 Running ./loop.sh > countdown_bg.txt &
[2]+ 85946 Stopped ./loop.sh > countdown_bg.txt
[3] 85947 Running ./loop.sh > countdown_bg.txt &
[4]- 85949 Running ./loop.sh > countdown_bg.txt &
Check running processes – ps
The ps command shows running processes initiated by the terminal. The process information includes PID (process ID), TTY (terminal name), TIME (processing time), and CMD (command name).
ps
PID TTY TIME CMD
85871 pts/2 00:00:00 bash
85945 pts/2 00:00:41 loop.sh
85946 pts/2 00:00:11 loop.sh
85947 pts/2 00:00:22 loop.sh
85949 pts/2 00:00:11 loop.sh
85950 pts/2 00:00:00 ps
-e option
The ps command shows the running processes that your terminal has initiated. The command doesn't show all the processes running on your computer. For example, processes initiated by the computer itself or initiated by other terminals are not shown. To display all the processes running on the computer, use the -e
option.
ps -e
PID TTY TIME CMD
1 ? 00:00:30 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
:
85947 pts/2 00:00:37 loop.sh
85949 pts/2 00:00:25 loop.sh
85952 pts/2 00:00:00 ps
There are processes with ?
in the TTY
field. This means the process is initiated by the computer itself and is not a job initiated by a user.