SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
hi,
i want a cron job to be run at 00:10AM every 3 weeks on a saturday. in other words, every 3rd saturday. is that possible?
i have tried:
#min hour dom month dow ...
10 0 */21 * 6 ...
is that right? it doesn't seem to work. the most important thing is "on saturday (6), every 3 weeks (*/21)" everything else not important.
no, it's not a problem with absolute path or root privileges.
so, do i have to add this entry to crontab exactly on a saturday for the */21 and 6 to coincide? i was thinking, if i add that entry on, for example, a wednesday, then cron will see, "oh, it's wednesday, so i'm not running it." then exactly 21 days later, cron sees again, "oh, it's a wednesday, so i'm not running it." so the */21 and 6 are never both satisfied, so the job will never run.
in the mean time, i will test the above hypothesis: have to make the */21 and 6 coincide.
Your command would, I believe, only run it any 21st of the month that falls on a saturday. The */21 field is "day of month", and is not sequential from month to month.
I would just run a script every saturday that decides if it's been 3 weeks. For example:
Code:
#!/bin/bash
BASE="/tmp/every_3_weeks"
if [ -f "${BASE}.1" ]
then if [ -f "${BASE}.2" ]
then rm ${BASE}.?
YOUR_COMMMAND_HERE
else touch ${BASE}.2
fi
else touch ${BASE}.1
fi
Originally posted by Matir Your command would, I believe, only run it any 21st of the month that falls on a saturday.
hmm, i thought "21" would mean the 21st of a month. i use the "*/" as suggessted by a tutorial somewhere. i tried using "*/2" for min and "*" for other things, then it does indeed run every 2 minutes.
Quote:
I would just run a script every saturday that decides if it's been 3 weeks.
Yes, well, technically */21 means "Every 21st day of the month", but given that such a range is 1-31 limits things greatly. It *might* try it on the 1st and 22nd, I'm not certain. The point is that its based on the date, not on the last running of the cronjob.
I have an idea. Theoretically, the 3rd Saturday of the month can only fall between the 15th (if the 1st of the month is a Saturday) to the 21st (if the 1st of the month is a Sunday). So you could just create multiple entries that cover each possibility:
I thought Berhanie mentioned that that syntax would execute everyday between the 15th and the 21st PLUS every Saturday.
You rightly point out that the original request was for "every 3rd Saturday". That said, your solution above (on closer inspection) would do the trick.
Originally posted by Berhanie Unfortunately, that would run at 00:10 on the 1st through the 7th (1-7) of each month, plus every saturday (6).
gosh, if that's true, then i find cron very counterintuitive (read sucky ).
my intuition is that the date/time columns are ANDed: (0hour) AND (10min) AND (dom is 1, 2, ..., or 7) AND (dow is saturday) AND (any month).
Originally posted by rgiggs gosh, if that's true, then i find cron very counterintuitive (read sucky ).
my intuition is that the date/time columns are ANDed: (0hour) AND (10min) AND (dom is 1, 2, ..., or 7) AND (dow is saturday) AND (any month).
yea yea i just read more carefully, and "If both the dom and dow are specified, the command will be executed when either of the events happen." arghh
I think i would use 'at' instead.
It can check and run the command when i start up the computer if it was offline during the specified time.
And also it can mail me errors.
So if it's an importent task i would rather use 'at'
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.