Hi,

I am facing problems in scheduling the cron to run on first monday of the everymonth.

Can anybody help me out?

Regards,
sri

Recommended Answers

All 3 Replies

Sure. Post the cron line you're using. Please use code tags when posting codes on daniweb:

[code=text] ...cron here...

[/code]

Hi,

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

Thanks!!

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 run_avg_cogs_datetest.sh :

#! /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.

Borrowed from:
http://www.unix.com/unix-dummies-questions-answers/2551-crontab-first-monday-month-only.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.