I am facing problems in scheduling the cron to run on first monday of the everymonth.
Can anybody help me out?
Sure. Post the cron line you're using. Please use code tags when posting codes on daniweb:
[code=text] ...cron here...
This is what is I am using
30 00 1-7 * * [ "$(date '+%a')" == "Mon" ] ksh /u/dolfin/bin/run_avg_cogs.sh >> /u/dolfin/log/run_avg_cogs.LOG 2>&1
Does that ever run? I would put your evaluation in an external script and call that script from cron.
Install this in your crontab:
0 0 0 * 1 ksh /u/dolfin/bin/run_avg_cogs_datetest.sh
Then create the new file
#! /usr/bin/ksh day=$(date +%d) if ((day <= 7)) ; then exec /u/dolfin/bin/run_avg_cogs.sh >> /u/dolfin/log/run_avg_cogs.LOG 2>&1 fi exit 1
The cron job runs every every monday of the month, but your script only executes if its within the first 7 days of the month. So effectively the first monday of every month.