Is it possible for me to schedule cron to say run script A on the first Friday of the month, script B on the second Friday of the month, script C, etc.?
Thanks.
Scott
Scott Ehrlich wrote:
Is it possible for me to schedule cron to say run script A on the first Friday of the month, script B on the second Friday of the month, script C, etc.?
Yes. You just need to specify the "day of the week" and a "day of the month" with a range that can only happen for the first occurrence of the particular day in question:
00 12 1-7 * Fri command-for-first-friday-of-month 00 12 8-14 * Fri command-for-second-friday-of-month
Remember, cron must match *ALL* date/time specifiers.
I have not tested this, so it may not work as advertised.
Cheers, Michael
On Jan 28, 2008 1:26 PM, Scott Ehrlich scott@mit.edu wrote:
Is it possible for me to schedule cron to say run script A on the first Friday of the month, script B on the second Friday of the month, script C, etc.?
There is always the lowly 'at' command. Setup and maintenance would be a pain as you would not easily be able to create a configuration that would run in perpetuity. But perhaps you could write a script to generate each months 'at' schedule and run that with cron.
If you control the scripts that are being run, perhaps you could run them on a regular schedule and program them with the logic needed to decide whether or not they should do anything.
-- Jeff
On Jan 28, 2008 2:26 PM, Scott Ehrlich scott@mit.edu wrote:
Is it possible for me to schedule cron to say run script A on the first Friday of the month, script B on the second Friday of the month, script C, etc.?
I think you can make cronjob run on every Friday, and in your script check if date is 2nd (3rd) Friday.
OTOH, if you specify days and day of week, I think they will both match, which is not what you want.
I found this with google: http://www.computing.net/unix/wwwboard/forum/2731.html
Which leads to something along these lines ...
day=`date +%d`
if [ $day -ge 8 -o $day -le 14 ]; then
echo javascript:void(0) '2nd Friday'
# do F2
elif [ $day -ge 15 -o $day -le 21 ]; then
echo javascript:void(0) '3rd Friday'
# do F3 fi
HTH, -Bob
Sloppy cut-n-paste error using -o, so this is obviously wrong ...
day=`date +%d`
if [ $day -ge 8 -o $day -le 14 ]; then
echo '2nd Friday'
# do F2
elif [ $day -ge 15 -o $day -le 21 ]; then
echo '3rd Friday'
# do F3 fi
maybe something more like this:
day=$(date +%d) [[ $day -le 7 ]] && echo "1st Friday" && do_F1 && exit [[ $day -ge 8 && $day -le 14 ]] && echo "2nd Friday" && do_F2 && exit [[ $day -ge 15 && $day -le 21 ]] && echo "3rd Friday" && do_F3 && exit [[ $day -ge 22 && $day -le 28]] && echo "4th Friday" && do_F4 && exit
-Bob