Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`watch jobs` doesn't work in linux

Tags:

linux

csh

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?

like image 202
SIMEL Avatar asked Apr 05 '11 16:04

SIMEL


People also ask

What is a job on Linux?

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.

What does no job control in this shell mean?

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.

How do you stop a stopped job in Linux?

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.


2 Answers

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.

like image 88
Eric Johnson Avatar answered Nov 12 '22 07:11

Eric Johnson


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.

like image 20
flolo Avatar answered Nov 12 '22 08:11

flolo