I need to execute a script on the first working day (M-F) of every month. I tried to configure cron and it doesn't allow me to do this. Is there any way I could do it?
You want to execute the job if it's the 1st of the month and a working day, or if it's the 2nd or 3rd and a Monday, right?
You could write a little script (call it 'wd1') like:
[tt]
#!/bin/bash
DOM=`date +%e`
DOW=`date +%a`
exit $( \
[ $DOM -eq 1 -a $DOW != 'Sat' -a $DOW != 'Sun' ] \
|| [ $DOM -le 3 -a $DOW == 'Mon' ]
[/tt]
Then you could set the following command to run every day (or just the 1st 3 days of the month):
[tt]
wd1 && monthlyjobscript
[/tt]
this solution will run your script on the first Monday of every month.
This is not what you asked for in your first post.
Did you change your mind in the meantime?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.