On Mon, Aug 5, 2013 at 2:00 AM, Gordon Messmer gordon.messmer@gmail.com wrote:
On 08/04/2013 10:17 PM, zGreenfelder wrote:
or... if it really has to be on the first Saturday and only on the first Saturday, then running something like 15 4 1-7 * * /home/app/oracle/backup/monthlybk.sh
with the top of the monthlybk.sh script doing soemthing like
No, really. We went over this. You don't have to modify your scripts. You can put the "test" in the crontab. John's example should work properly:
15 04 * * 6 test $(date +"%d") -le 07 && /home/app/oracle/backup/monthlybk.sh
Cron will run those commands every Saturday. On the first Saturday in the month, "test" will succeed and the script will be run.
On the other hand, putting the test in the script - perhaps with a command line option to override - would also keep it from doing something wrong even if someone happens to run it manually at the wrong time. If I were doing it, I might touch a file when starting and check the timestamp of that to avoid running more than one even on the right day. Sometimes the most clever way isn't really the best.