Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
cronjob - Second tuesday of the month?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Thu Sep 23, 2010 8:05 pm    Post subject: cronjob - Second tuesday of the month? Reply with quote

I'm trying to see if this is possible, but I don't see much in crontab(5) or online. Is this possible without additional coding?
Back to top
View user's profile Send private message
madchaz
l33t
l33t


Joined: 01 Jul 2003
Posts: 993
Location: Quebec, Canada

PostPosted: Thu Sep 23, 2010 8:43 pm    Post subject: Reply with quote

afraid not. The way cron works is you can specify the following.

Minute, hour, day of month, month, day of week.

So you could specify the second day of the week, but not the second day of the second week.
_________________
Someone asked me once if I suffered from mental illness. I told him I enjoyed every second of it.
www.madchaz.com A small candle of a website. As my lab specs on it.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Thu Sep 23, 2010 9:17 pm    Post subject: Reply with quote

BTW I'm wondering whether "2/2" would gives the 2nd (but the 4th too) Tuesday of a month.
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Thu Sep 23, 2010 9:54 pm    Post subject: Reply with quote

http://www.unix.com/302310344-post3.html
http://www.linuxquestions.org/questions/general-10/cronjob-for-every-second-saturday-of-the-month-707436/#post3457944

Maybe one of this is of help. Without additional coding, I don't think so, but it maybe dependend on which cron you're using exactly.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
javeree
Guru
Guru


Joined: 29 Jan 2006
Posts: 453

PostPosted: Fri Sep 24, 2010 7:58 am    Post subject: Reply with quote

second tuesday of the second week should always fall somewhere between the 7th and the 13th =>

#Minute, hour, day of month, month, day of week.
minute hour 7,8,9,10,11,12,13 month 2
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Fri Sep 24, 2010 8:03 am    Post subject: Reply with quote

javeree wrote:
second tuesday of the second week should always fall somewhere between the 7th and the 13th =>

#Minute, hour, day of month, month, day of week.
minute hour 7,8,9,10,11,12,13 month 2
Doesn't this mean : "run from 7th till 13th _and_ every Tuesday" ?

BTW I contacted the author of vixie-cron. He wrote:
Quote:
there is no posix cron syntax for second tuesday, but if you have a proposal and a patch (including code and documentation) i'll look at it.
Back to top
View user's profile Send private message
javeree
Guru
Guru


Joined: 29 Jan 2006
Posts: 453

PostPosted: Fri Sep 24, 2010 12:47 pm    Post subject: Reply with quote

I understand this means:

run whenever the date is one of 7 to 13 AND it is a tuesday (AND, not OR).
If you want or, you need to have different lines.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Fri Sep 24, 2010 2:05 pm    Post subject: Reply with quote

please ... read the man page :
Code:
Commands are executed by cron(8) when  the  minute,  hour,  and
       month  of  year  fields  match  the current time, and when at least one of the two day fields (day of
       month, or day of week) match the current time (see ``Note'' below).
Back to top
View user's profile Send private message
wthrowe
Tux's lil' helper
Tux's lil' helper


Joined: 19 Aug 2009
Posts: 141

PostPosted: Fri Sep 24, 2010 2:06 pm    Post subject: Reply with quote

Unfortunately, toralf is right. Seems like the other behavior would be more useful.
crontab(5) wrote:
Note: The day of a command's execution can be specified by two fields -- day of month, and day of week. If both fields are restricted (ie, aren't *), the command will be run when either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
Back to top
View user's profile Send private message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Fri Sep 24, 2010 2:49 pm    Post subject: Reply with quote

So to sum it all up, it cannot do it.
Back to top
View user's profile Send private message
wthrowe
Tux's lil' helper
Tux's lil' helper


Joined: 19 Aug 2009
Posts: 141

PostPosted: Fri Sep 24, 2010 4:02 pm    Post subject: Reply with quote

msalerno wrote:
So to sum it all up, it cannot do it.

cron can't do it alone, but you could easily put
Code:
[ `date +%u` = 2 ] && foo
as a command in the crontab to run every day from the 8th to the 14th of each month in order to get foo run on the second Tuesday.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum