Crontab schedule once a month problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Crontab schedule once a month problem

runo nere
Hi Erman,

I want to run a script and it must run on the first sunday of month

I am trying this but it works today(01.02.2017) ;

52 13 1-7 * 0 ls > style.txt

I didnt find logical answer but i saw a post about this;

"""but there's no method to say "only the first Sunday". You can, however, modify your script to check which sunday it's being run on, and simply exit if it's not the first one."""

IS THAT TRUE?????
Reply | Threaded
Open this post in threaded view
|

Re: Crontab schedule once a month problem

ErmanArslansOracleBlog
Administrator
Hi,

Here is an example cron entry for you.. I didn't tested it, but it looks okay.

00 09 * * 7 [ $(date +\%d) -le 07 ] && /run/your/script

You can change the name of the script also, the minute and hour columns (00 09) according your needs.. Don't change anything else.
Put this in crontab (using crontab -e) and test it. It should work.
Reply | Threaded
Open this post in threaded view
|

Re: Crontab schedule once a month problem

nuro
ty it worked (: