LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2010, 07:26 PM   #1
ezekieldas
Member
 
Registered: Mar 2010
Posts: 122

Rep: Reputation: 16
crontab run every 180 mins


I recently changed a job to run from every 15 mins:

*/15 * * * * /usr/local/bin/go.sh

to run every 180 mins:

*/180 * * * * /usr/local/bin/go.sh

But instead it ran every hour, on the hour.

I changed to this and I think it'll work:

* */03 * * * /usr/local/bin/go.sh


But why did I get that behavior? I found one post that notes this is what vixie cron does -- but the manual page doesn't elaborate -- or I'm overlooking the explanation.

vixie-cron-4.1-36.EL4
 
Old 10-06-2010, 07:57 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Well ... there's
minute hour day columns for a reason.

To me it seems "natural" that once I exceed the range
of 60 minutes I choose hours.



Cheers,
Tink
 
Old 10-06-2010, 07:59 PM   #3
ezekieldas
Member
 
Registered: Mar 2010
Posts: 122

Original Poster
Rep: Reputation: 16
natural? Interesting.
 
Old 10-07-2010, 12:18 AM   #4
speck
Member
 
Registered: Nov 2001
Location: US
Distribution: Slackware 14.2
Posts: 341

Rep: Reputation: 83
From the man page, this should make it more clear.

Code:
field         allowed values
-----         --------------
minute        0-59
hour          0-23
day of month  1-31
month         1-12 (or names)
day of week   0-7 (0 or 7 is Sun)
 
Old 10-07-2010, 04:45 PM   #5
ezekieldas
Member
 
Registered: Mar 2010
Posts: 122

Original Poster
Rep: Reputation: 16
The man page is interesting too but the subsequent action is this:


*/180 * * * * foo
OK

180 * * * * foo
bad minute
errors in crontab file, can't install.

----
Possibly a bug, confusing nonetheless...
 
Old 10-08-2010, 01:34 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by ezekieldas View Post
180 * * * * foo
bad minute
errors in crontab file, can't install.

----
Possibly a bug, confusing nonetheless...
Not a bug, given the allowed values are 0-59 as stated above..
 
Old 10-08-2010, 02:40 AM   #7
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
If you want to run cron every three hours, you use:

Quote:
00 */3 * * * command
This will ensure that it runs only once every 3 hours, and not every minute of that third hour.

You can also use

Quote:
* 0,3,6,9,12,15,18,21 * * * /your/command

Last edited by prayag_pjs; 10-08-2010 at 02:42 AM.
 
Old 10-08-2010, 04:52 PM   #8
rustek
Member
 
Registered: Jan 2010
Location: Melbourne, IA, USA
Distribution: Ubuntu
Posts: 93

Rep: Reputation: 8
Hi,

1 */3 * * *
is what you want.

* */3 * * *
will run it every minute of
every third hour.

I think prayag_pjs typo'd the one line
* 0,3,6,9,12,15,18,21 * * *
as it will also run every minute of
every stated hour.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
run script for X mins mitchell2345 Linux - Newbie 1 06-16-2009 06:08 PM
[SOLVED] run a command automatically after every 10 mins vikas027 Programming 3 08-03-2008 06:37 PM
how to run a schedule in every 2 mins!! rahulrawat Red Hat 7 12-24-2005 07:58 PM
hard crash after 20 mins. every time on first boot reboot and it will run ok bejamin1 Mandriva 5 02-02-2004 01:42 PM
how to set cron job to run every 5 mins? gsbarry Linux - General 7 05-28-2003 01:30 PM


All times are GMT -5. The time now is 08:02 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration