Cron schedule for the first Sunday of every month

30 January,2014 by Tom Collins

Question: How do I schedule a cron job (or crontab job) for for the first Sunday of every month?

Answer:  To schedule a job to run on the first Sunday of every month , use the crontab example as a template.

This example executes a script at 2am on a Sunday where the day of the month is between 1 and 7. Adjust according to your needs

Before we look at a solution - a couple of notes around potential gotchas when it comes to creating a cron job 

The relationship between day of month and day of week fields are OR , not AND.   I have been caught out by this previously. 

 

00 02 1-7 * * [ "$(date '+\%a')" == "Sun" ] && /usr/local/bin/once_a_mth_first_Sunday


--every Sunday of first 7 days of the month
 , 
--cron reference
--min
--hour
--day of month
--month
--day of week

Read More

db2diag.log file delete on Linux and DB2

OLTP performance checklist

Author: Rambler(http://www.dba-db2.com)

Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Cron schedule for the first Sunday of every month

Comments are moderated, and will not appear until the author has approved them.


dba-db2.com | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright