Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run a program over SSH that keeps running when I disconnect. This Stack Overflow answer gave me the following command:

nohup sleep 30 > foo.out 2> foo.err < /dev/null &

Unfortunately, it doesn't seem to work. I login (ssh -Y) to a remote bash shell and execute it, disconnect, and come back within 30 seconds, but jobs shows nothing and the foo files also show nothing. Is there any other way I can run background jobs over ssh after I logout?

share|improve this question

migrated from stackoverflow.com Dec 20 '11 at 11:14

This question came from our site for professional and enthusiast programmers.

The sleep command does not generate any output, so you should expect the output files to remain empty. – tripleee Dec 20 '11 at 8:27
Oh, and jobs only shows processes that are descendants of the current shell. Try with ps | grep sleep instead. – tripleee Dec 20 '11 at 8:29
This does not seem a question related to ssh. – enzotib Dec 20 '11 at 11:27
Question is a bit confused. – EightBitTony Dec 20 '11 at 11:32
ssh user@server "echo /usr/run/my/job | at now +1 min"
share|improve this answer

jobs won't show anything if you spawned the process in another shell; the first line of its man page description is:

The jobs utility shall display the status of jobs that were started in the current shell environment

So you could ssh to the computer, sleep 30 &, and ssh from another window, and jobs still wouldn't show anything in that other window even though the process is obviously still running. The command you have works; try using ps or pgrep to check for it instead (e.g. pgrep sleep)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.