LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 04-30-2010, 03:20 PM   #1
noir911
Member
 
Registered: Apr 2004
Location: Baltimore, MD
Posts: 681

Rep: Reputation: Disabled
run cronjob once every three months


I am trying to run the following only once every three months but looks like it runs every day. I edited crontab -e and added the following:

Code:
0 23 * jul,oct,jan,apr * /path/to/script > /var/log/script.log 2>&1
Thanks.
 
Old 04-30-2010, 03:26 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
Try this:
Code:
0 0 1 1,4,7,10 * /path/to/script > /var/log/script.log 2>&1
if memory serves me you should also be able to do '0 0 1 */3 *'

edit: fixed typo and I'll note--
Code:
# .---------------- minute (0 - 59) 
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... 
# | | | | .---- day of week (0 - 7) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat 
# | | | | |
# * * * * *  command to be executed
Gets pasted into every crontab I edit typically, gives me an easy reference to double check against.

Last edited by rweaver; 04-30-2010 at 03:43 PM.
 
Old 04-30-2010, 03:30 PM   #3
tsg
Member
 
Registered: Mar 2008
Posts: 155

Rep: Reputation: 30
Your first '*' tells it to run every day. Pick a day of the month you want it to run on eg.

Code:
0 23 1 jul,oct,jan,apr * /path/to/script > /var/log/script.log 2>&1
will make it run on the first of every month.
 
  


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
cronjob to run every 15 minutes? your_shadow03 Linux - Newbie 5 11-19-2009 10:58 PM
[SOLVED] make cronjob run every 10mins qwertyjjj Linux - Newbie 2 08-13-2009 08:06 PM
only run cronjob when asteriks voip gives 0 on channels 1c3c0ld Programming 1 10-08-2008 07:07 PM
How to set up a Cron Job to run every other week or every three months etc. kckabobus Linux - Newbie 3 04-03-2008 01:36 PM
why do these cronjob not run? SheldonPlankton Linux - General 1 01-05-2005 08:01 PM


All times are GMT -5. The time now is 03:30 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 Google+: linuxquestions
Open Source Consulting | Domain Registration