jobs is my favorite command to see my codes which are running in the background. In order to check for them dynamically, I tend to type

watch 'jobs'

which does not display anything. However

watch 'ps'

works perfectly. I have been doing the same mistake for months now.

I think understanding why the first does not work while the second works can help me to stop doing the same error.

Can anyone help?


jobs is a built-in that reports on the state of the current shell: the commands that were backgrounded with that shell. watch runs a new shell for each execution, and that shell's jobs has no way of knowing what watch's parent shell's jobs are. ps is an external command and it never used the shell's state.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.