tags:

views:

100

answers:

5

I just want a bash script to run 5 minutes after it's called. What am I doing wrong?

I have the command:

/path/to/my/script | at now + 5 min

And yet the script runs right away every time.

+9  A: 

how about:

sleep 300 && /path/to/my/script
Amir Afghani
Yeah, this question didn't really need `at`. I'd suggest you use ``, so it can be cancelled.
Jack Kelly
Nice enhancement Jack
Amir Afghani
+12  A: 

You are executing the script immediately and sending its output into at. You need to send the name of the script itself into at:

echo /path/to/my/script | at now + 5 min
Jack Kelly
this is win....
Matt Joiner
And would the downvoter care to explain?
Jack Kelly
+1  A: 

Commands are evaluated left to right, so first your script gets executed, the output of it will be piped to the at command, this is normal behaviour. Have look at at the at man pages for more information.

Femaref
+1  A: 

The problem is you're running the script and piping the output to the at command. What you need to do is run the at command with the path to your script as a parameter. I'm not sure of the syntax, but at -h or man at should help.

Andrew Cooper
A: 
at -f /path/to/my/script -t now +5 minutes

This should work as far as scheduling a script to run at a specific time. For any more information on the "at" command try linuxmanpages.com. I may be wrong thought ( currently not at a linux system to test ).

Good luck anyways

oddenodin