Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to run a script at 6pm on a remote server but don't want to wait around to trigger it. I don't want to use cron since it's a one time deal.

Can I do something like "nohup myscript &" with a "sleep" or "after" command?

Thanks!

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

Are you sure you aren't looking for something like at.

share|improve this answer
    
I think you're right! would you mind posting the right syntax? is it "nohup script.sh | at now +4 hours &" ? (just a guess, clearly! thanks –  user41172 Apr 21 '10 at 22:43
    
at queues and executes whatever you give it on stdin, so syntax is e.g. 'echo script.sh | at now +4 hours'. you don't need nohup with at. see the man page for at for more details. –  cas Apr 22 '10 at 0:36
add comment

You can use the at (man at) command to do this, and then you don't need the nohup.

If you really wanted to, you could:

nohup bash -c 'sleep 5; command' &

But you might be better off running the command in screen and then use sleep before it so you can easily check the output.

share|improve this answer
add comment

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.