Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Cron execute program on first wednesday on month

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
gaijin
Posts: 16
Joined: 2016-11-22 12:08

[Solved] Cron execute program on first wednesday on month

#1 Post by gaijin »

Hello
I want set cron to execute program on first wednesday on month
I try:

Code: Select all

cat /etc/crontab 
30 13 1-7 * 3   root    script.sh
but http://cron.schlitt.info say:
2017-12-01 13:30:00
2017-12-02 13:30:00
2017-12-03 13:30:00
2017-12-04 13:30:00
2017-12-05 13:30:00
2017-12-06 13:30:00
2017-12-07 13:30:00
2017-12-13 13:30:00
2017-12-20 13:30:00
2017-12-27 13:30:00

Someone have a idea
Last edited by gaijin on 2017-12-05 08:06, edited 1 time in total.

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: Cron execute program on first wednesday on month

#2 Post by pylkko »

Use a timer.

for example

Code: Select all


OnCalendar=Wed *-*-01..07 12:00:00
Would run every first - seventh day of the month at noon, but only if it is a Wednesday

see more in the manual:
https://manpages.debian.org/stretch/sys ... .5.en.html

You can add how ever many other conditions you want. Also, if the computer is off, it will run first when you turn it back on (if you want, that is. This cannot be done at all with cron). Or have it run on Wednesdays after 13:30 whenever the computer becomes idle.

gaijin
Posts: 16
Joined: 2016-11-22 12:08

Re: Cron execute program on first wednesday on month

#3 Post by gaijin »

wizard10000 wrote:

Code: Select all

30 9 * * 3 [ `date +\%d` -le 7 ] && /path/to/task/goes/here
This job will only run on Wednesdays and will exit if the Wednesday is not within the first seven days of the month. You can adjust the time, but this one fires off at 9:30am.

Hope this helps -
Perfectly. A man learns his whole life.

Post Reply