Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Tried:

while true; do date; sleep 1; done

Got:

Thu Aug 27 17:33:24 IDT 2009
Thu Aug 27 17:33:25 IDT 2009
Thu Aug 27 17:33:26 IDT 2009
...

But:

nohup while true; do date; sleep 1; done

Got me:

bash: syntax error near unexpected token `do'

Any ideas why?

share|improve this question
up vote 4 down vote accepted

If you REALLY wanted to do it all on the command line without making a script, do this:

nohup bash -c "while true; do date; sleep 1; done"
share|improve this answer
    
+1 & correct, Short and to the point. thanks! – Adam Matan Aug 27 '09 at 15:16

nohup takes a command, "while" is not a command, it is a shell builtin.

share|improve this answer

while is actually a command that is built into bash, not a separate executable, so nohup can't run it. If you want to do this, you'll need to put your commands into a file and then use nohup to run that file.

share|improve this answer

Your Answer

 
discard

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

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