Force CRON to run a job once again, despite the crontab settings
I run a script once a day. When the cron daemon runs the script I get a neat email from CRON containing the output of the script which I cant get if I run it manually.
Now sometimes I want to run this script right away but it takes an hour to run so I want to go away after initiating it and still get that email. How do I force the cron daemon to run the script once again today right away instead of running the script directly or fiddling with the daily run time settings? Is it possible? Or in other words how do I run a nohup script in background mode and send the output to my mail with subject containing the word CRON ? Sorry I am new to linux. |
Check the "batch" and "at" command man pages.
"batch" will do the same thing as "at now". Both are entries in the cron queue, but are only run once. One thing the script might need to check on is whether the script is already active or not. This is sometimes a problem with colliding output file names or file data being updated (a second run while the first is running may wipe out the results of the first, or may cause data corruption). |
at now -f script.sh worked
but now I have another problem. the script ran ie I was able to see ps aux while it was running. But I didn't get any email. This is because my email filter auto deletes any mail that doesn't have CRON or Software in the subject line. Does 'at' send the email with a different subject? What word should be added to the filter to allow mail from at? I hope it is not a generic word like 'at'. That word would let in too many spam mails. Is there a way to manually direct the output of a script to the mail specifying my own subject line in the command? |
My cron doesn't use CRON in the subject - is this a configuration you set in the crontab file?
The only way I have found is: Code:
/path_to_script/script 2>&1 | mailx -s "Subject" userid@hostname You can do this with: Code:
$ at now |
I know it has been many years. But I wanted to share how I solved this.
I will run date and then I will do crontab -e and then change the time to 43 * * * * if 43 was the next minute. After the next minute after verifying the job has started I will do crontab -e and restore the original settings. Now after the job finishes CRON will send out the mail as usual. |
All times are GMT -5. The time now is 02:49 AM. |