Cronjob confirm.

I have a job to be executed every 1st and 3rd sunday of every month.

00 13 1-7 * 0 /.../....sh for the 1st sunday and a next script for 3rd.

00 13 15-21 * 0 /..../...sh -- hoping that 1st and 3rd sunday would fall between these days.

( O R )

can i combine both in one,

00 13 1-7,15-21 * 0 /..../...sh -- would this work?

Is there any other better way to do this?

[406 byte] By [shankie] at [2007-11-26 8:33:24]
# 1

> I have a job to be executed every 1st and 3rd sunday

> of every month.

>

> 00 13 1-7 * 0 /.../....sh for the 1st sunday and

> a next script for 3rd.

No. That's not the way cron works. See the crontab man page:

Example 3: Specifying Days of the Month and Week

This example runs a command on the first and fifteenth of

each month, as well as on every Monday:

0 0 1,15 * 1

So your script would run the first seven days of the month and also on all other sundays.

Instead, you should just have cron run your script every sunday, then have the script itself check the date and exit if its not the first or third.

Use 'date +%d' and check that it falls into the correct range.

--

Darren

Darren_Dunham at 2007-7-6 21:59:00 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 2
Thanks Daren!
shankie at 2007-7-6 21:59:00 > top of Java-index,Solaris Operating System,Solaris 10 Features...