I want to use watch jobs
to see an updated showing of all the jobs I have running, but when I try to do it, all I get is the headline of watch and a blank screen. But using the script
while (1)
sleep 10;
clear;
jobs;
end
does work, where is the problem?
In Linux, a job is a process that the shell is managing and hasn't finished running. Every job has a unique ID that you can use to control it regardless of whether it is in the background or foreground of your terminal session. By using the jobs utility, you can retrieve a list of all currently running jobs.
Without job control, you have the ability to put a job in the background by adding & to the command line. And that's about all the control you have. With job control, you can additionally: Suspend a running foreground job with Ctrl Z. Resume a suspended job in the foreground with fg.
It's rather easy to kill stopped processes launched from the same terminal. All we need to do is find the process IDs of the jobs and then send the SIGKILL signal to them. Here, we use –p for getting the process ID, while –s filters only for processes that are stopped.
Job control is managed by the shell and jobs
is a shell builtin function. If you use the command which jobs
you will see there is no binary called jobs anywhere in your $PATH.
watch
is doing a system call every two seconds so shell functions aren't available to it.
You could also try watch 'ps awwwux | grep yourusername'
. But its not quite the same as jobs
.
Job is not a system command its a shell command - when you start watch he executes a subshell which has its own job managment and of course no jobs. Try watch ps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With