954,234 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Cron Scheduling problem

Hi,

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

Can anybody help me out?

Regards,
sri

srikanthn9
Newbie Poster
2 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

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

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

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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!!

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

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

srikanthn9
Newbie Poster
2 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

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

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: