开发者

`watch jobs` doesn't work in linux

开发者 https://www.devze.com 2023-02-22 19:22 出处:网络
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 bla开发者_如何学Gonk screen. But using the script

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 bla开发者_如何学Gonk screen. But using the script

while (1)
  sleep 10;
  clear;
  jobs;
end

does work, where is the problem?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消