Perhaps you have several processes running in the background:
$ jobs [1] Stopped teamviewer [2]- Stopped vim [3]+ Stopped firefox
use: fg %2
to bring the vim process to the fore.
To send the last process to the forefront, simply use: fg
without arguments.
- You can also enter% process_name to resume a stopped process.
To pause a process running in the background , use:
kill -19 %job_id.
Signal -19
is SIGSTOP (signal sent using Ctrl-Z).
you can always view the list by typing kill -l
Moving jobs between background / foreground:
If you already typed a command and forgot to use &
, you can transfer the foreground job in the background by typing ^Z (CTRL-Z)
to pause the job and then bg
to put it in the background
$ sleep 99 ^Z [1]+ Stopped sleep 99 $ bg [1]+ sleep 99 &
You can list the jobs of the current shell using the jobs
command.
Just remember that βexiting the shellβ also affects the operation:
- Jobs running in the background when you exit the shell are running.
- Jobs paused ("Stopped") when the shell completes are completed.
Sending signals to tasks and processes
You can send signals, including completion signals, to jobs that are launched from the current shell using job numbers, using% (JOBID) instead of process numbers (PID):
$ kill %1 [1]+ Terminated sleep 99
To send signals to processes or jobs that do not start from the current shell, you first need to use ps
to find their process numbers (PIDs).
You can refer to this link: processes and tasks
Common job management commands on Linux:
- jobs - list of current jobs
- fg - resume the next job in the queue
- fg % [number] - resume work [number]
- bg - click the next job in the queue in the background
- bg % [number] - click the task [number] in the background
- kill % [number] - kill the task with the number [number]
- kill - [signal]% [number] - send a signal [signal] to the task number [number]
- disable % [number] - cancel the process (the owner of the terminal will no longer be), so the command will be available even after the terminal is closed.
That is almost all of them. Pay attention to the% infront job numbers in the commands - this is what says you are talking about work, not about processes.