Maybe you could have cron entry that looks like this ...
30 * * * * script1 && script2 && script3
Provided that scripts do exit 0 when they complete successfully
and exit something other than zero when there is an error.
| Plankton: 1% Evil, 99% Hot Gas. |
| [reply] [d/l] |
You could always do it with a 4th perl script, that runs the other 3.
#! /usr/bin/perl -w
use strict;
system('perl script1.pl') && exit(1);
system('perl script2.pl') && exit(2);
system('perl script3.pl') && exit(3);
exit(0);
- Tom | [reply] [d/l] |
Anonymous Monk,
Not really a Perl question, but here goes.
Running these scripts from cron as root is usually not a good idea. You want to make sure the ownership/permissions on the scripts themselves are correct. Depending on what you mean by "ended without errors", you might be able to just get away with checking the exit status. On the other hand, the script may complete but still encounter problems.
If this is the case and you want to be sure it is safe to continue, here is how I would do it:
- Have cron delete the "ok-#" files before calling the first script
- Have the first script's last item of business be to create the "ok-1" file
- Have the second script exit if the "ok-1" script doesn't exist
- Have the second script's last item of business be to create the "ok-2" file
- Have the third script exit if the "ok-2" script doesn't exist.
- Have the third script's last item of business be to create the "ok-3" file
- Have cron check for the existance of all 3 "ok" files and email you with either "success" or "failure"
Now this method is not without gotchas. Perhaps the script ran fine but couldn't create the "ok" file. Maybe someone deleted it during the window of opportunity (after the first script created it and the next script read it).
Cheers - L~R | [reply] |
One suggestion, hardcode any path to programs/scripts that you want to access in the script, just in case because you are running the script as root. And make sure only root can modify the script. | [reply] |