LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 02-03-2012, 12:41 AM   #1
CobusA
LQ Newbie
 
Registered: Oct 2011
Posts: 4

Rep: Reputation: Disabled
Cron does not fire as expected on Redhat


Hi

My entry in crontab file is:
15 */2 1-7,14-21 * 3 /var/lib/command.

My expectation is: My command must execute every first and third Wednesday of the month.

Currently it executes on the 1st and 2nd and 3rd of the month and it ignores the 3 (for Wednesday) at the end.

Thanks
Cobus
 
Old 02-03-2012, 10:26 AM   #2
rknichols
Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 209

Rep: Reputation: 82
Quote:
Originally Posted by CobusA View Post
My entry in crontab file is:
15 */2 1-7,14-21 * 3 /var/lib/command.

My expectation is: My command must execute every first and third Wednesday of the month.
Your problem is with your expectation. As written, your job will be executed on the first 7 days of each month, on days 14-21 of each month, and also on any Wednesday. From "man 5 crontab":
Code:
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.
The standard cron daemon can't do what you want here. Your best solution would be to execute the job every Wednesday and have the job itself check whether the date is in the appropriate range, and exit with a zero return code and without writing to stdout or stderr if not.
 
Old 02-06-2012, 12:32 AM   #3
CobusA
LQ Newbie
 
Registered: Oct 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks, I'll implement your suggestion.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cron entry not working as expected td3201 Linux - General 2 07-25-2010 12:07 PM
When is redhat 5 expected to be released extendedping Red Hat 5 03-15-2007 08:16 AM
How to replace fire fox 1.5.0.9 with fire fox2 in mepis 6.0 redhead277 LinuxAnswers Discussion 0 02-21-2007 01:19 PM
Need to configure fire drive in Redhat Advance Server 2.1 . oberai Linux - Hardware 1 09-02-2003 07:38 PM
fire configuration with RedHat 7.1 fails basti Linux - Networking 0 12-11-2001 04:09 PM


All times are GMT -5. The time now is 02:44 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration