IT dragons tamed since 2006 (with 743 solutions and growing)

[login]
[join]

your IP[54.162.44.105]




If you thought this solution was helpfull, please login and vote. Not a member? click here

ID736
TitleHow to setup cron to run on only one named day of the month?
Byjohn
Keywordscron crontab
CategorySolaris
Votes0
Views57
Score57
Date2017-02-02
Body
First Tuesday of the month:

5 9 * * 2 [ `date +%d` -le 7 ] && /yourscript

5 = minutes 0:05
9 = hour 9am
* = calendar day, all
* = month, all
2 = weekday Tue
[ `date +%d` -le 7 ] && /yourscript = command

First Sunday of the month:

0 9 * * 0 [ $(date +%d) -le 07 ] && /yourscript

Second Sunday of the month:
0 9 * * 0 [ $(date +%d) -ge 8 -a $(date +%d) -le 14 ] && /yourscript


Some systems (Not many) support special characters and words. Solaris and RHEL do not

Entry Description Equivalent to
@yearly (or @annually) Run once a year at midnight of 1 January 0 0 1 1 *
@monthly Run once a month at midnight of the first day of the month 0 0 1 * *
@weekly Run once a week at midnight on Sunday morning 0 0 * * 0
@daily Run once a day at midnight 0 0 * * *
@hourly Run once an hour at the beginning of the hour 0 * * * *
@reboot Run at startup N/A
Field Required Allowed values Allowed special characters Remarks
Minutes Yes 0-59 * , - -
Hours Yes 0-23 * , - -
Day of month Yes 1-31 * , - ? L W -
Month Yes 1-12 or JAN-DEC * , - -
Day of week Yes 0-6 or SUN-SAT * , - ? L # -
Year No 1970–2099 * , - This field is not supported in standard/default implementations.
Third Friday of the month: 1 1 * * 5#3 /yourscript Last Friday of the month: 1 1 * * 5L /yourscript
SharediggDigg this solutiondel.icio.usPost to del.icio.usSlashdotSlashdot it!email to a friend
PrintPrint This Solution Print
If you thought this solution was helpfull, please login and vote. Not a member? click here


Latest News

Thanks to Dave for hosting this site!

Registered User Area

[login]
[new user]


Paying the Rent



Advanced Search:

Choose body, keywords, title, or all to include in search 
words to include in search 
and(+)

Choose body, keywords, title, or all to include in search 
additional words to include in search 
not(-)

Choose body, keywords, title, or all to exclude in search 
words to exclude from search 


catagory
order by






diggDigg Dracko
del.icio.usPost to del.icio.us
SlashdotSlashdot us!




Don't forget to vote!
Powered by John Core
Bye!

Dracko by John Core

me

View John Core's profile on LinkedIn


Certifications
security logo saber ccsa logo ccna-logo hbss veritas

Technologies
oracle_logo
solaris_logo linux-logo openstack_logo vbox_logo splunk storagetek_logo sun_logo oraclevm_logo brocade_logo bsd_logo

Languages
c-logo bash-logo php-logo

Employers
PlanetPayment Medecision AWi PennStateHershey DISA DLA cim Sun

Consulting
KMBS PNC FBI CCS PTD Sentinel