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.
basic 3. /usr/bin/vim. tiny 4. /bin/ed Choose 1-4 [1]: Make a new line at the bottom of this file and insert the following code. Of course, replace our example script with the command or script you wish to execute, but keep the */5 * * * * part as that is what tells cron to execute our job every 5 minutes.
If you want to run a program or script in the background on Linux then cron job is very important. With the help of cron jobs, you can execute a program or script in the background after a given interval of time.
What you could do is write a shell script with an infinite loop that runs your task, and then sleeps for 5 seconds. That way your task would be run more or less every 5 seconds, depending on how long the task itself takes. You can create a my-task.sh file with the contents above and run it with sh my-task.sh .
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
how about:
sleep 300 && /path/to/my/script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With