LinuxQuestions.org
Visit Jeremy's Blog.
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 01-29-2013, 01:46 PM   #1
sangfroid
LQ Newbie
 
Registered: Mar 2012
Posts: 10

Rep: Reputation: Disabled
crontab


Hi,

Just a quick question.

Is the following crontab supposed to run on every 5 minutes of monday between 10-12

*/5 10-12 * * 2

?
 
Old 01-29-2013, 02:04 PM   #2
truecipher
LQ Newbie
 
Registered: Jun 2012
Location: NC
Distribution: Debian /Mint/Scientific
Posts: 27
Blog Entries: 1

Rep: Reputation: Disabled
-- -- -- -- --
min hr dom mon dow
0-59 0-23 1-31 1-12 0-6

min: Minute
hr: Hour
dom:: Day of Month
mon: Month
dow: Day of Week

*/5 would run every 5 minutes
but I don't think you can specify time as you wish. You may have to add several lines:
One line for each hourly block:

*/5 10-11 * * 2
*/5 11-12 * * 2
 
Old 01-29-2013, 02:06 PM   #3
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,676

Rep: Reputation: 956Reputation: 956Reputation: 956Reputation: 956Reputation: 956Reputation: 956Reputation: 956Reputation: 956
I'm not sure about the 10-12 part, but you could just specify 10,11,12 instead. Also, the day of week value has Sunday at 0, so 2 would be Tuesday.

*/5 10,11,12 * * 2

If you want to test it, just add a dummy entry like so:
Code:
*/5 10,11,12 * * 2 echo $(date) >> /home/user/crontest.out
Replacing the 2 for the day of week with the current day. Then just check crontest.out after the day is over to see which times were run.

Last edited by suicidaleggroll; 01-29-2013 at 02:08 PM.
 
1 members found this post helpful.
Old 01-29-2013, 02:32 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
The syntax is correct even for the hour field.
Code:
*/5 10-12 * * 2
Just take in mind that it will run till 12:55, not 12:00 as maybe supposed to do. Regarding the day of the week, the only caveat is that if you specify both the day of the month AND the day of the week, the effect is additive: it means it will run on both the specified days of the month AND every specified day of the week. Since the day of the month is not restricted here, it will run only on every Tuesday (not Monday as mentioned in the first post).
 
3 members found this post helpful.
Old 01-29-2013, 02:54 PM   #5
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
There is a simple web app that allows you to edit your crontab.

It is at http://www.corntab.com/

From the web page.

Corntab is a simple crontab web GUI
With Corntab you can ensure that you always have the correct crontab syntax.

Don't worry about forgetting the proper crontab format for a particular Linux distribution because Corntab let's you click on all of the crontab options and outputs your crontab entry in real-time.

There is nothing to install.
 
Old 01-30-2013, 04:36 PM   #6
mlbx
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
See results from crontab values

If you enter the crontab values at the CronBuddy website you will see a forward schedule of run times.
 
Old 01-31-2013, 05:11 AM   #7
truecipher
LQ Newbie
 
Registered: Jun 2012
Location: NC
Distribution: Debian /Mint/Scientific
Posts: 27
Blog Entries: 1

Rep: Reputation: Disabled
Re: Corntab and CronBuddy

Re: Corntab and CronBuddy

Maybe its just me but way over half the fun of Linux is using the terminal and scratching notes in a notebook of different commands and arguments. I duckduck things and read man pages and take notes for future reference.

example:
Code:
mpg123 -w name.wav name.mp3
...is so much cooler than using a GUI software package. Also, it impresses women worth knowing...
 
Old 01-31-2013, 12:07 PM   #8
vipin310379
LQ Newbie
 
Registered: Jan 2013
Location: Moga, Punjab
Distribution: Redhat
Posts: 19

Rep: Reputation: Disabled
*/5 10-12 * * 2
(it will run the job on Tuesday from 10.00 to 12.55 every five minutes interval)

*/5 10-11 * * 1
(it will run the job on Monday from 10.00 to 11.55 every five minutes interval)
 
Old 04-02-2013, 06:02 AM   #9
mlbx
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
Quote:
Originally Posted by mlbx View Post
If you enter the crontab values at the CronBuddy website you will see a forward schedule of run times.
This interactive cron simulator is now athttp://www.dataphyx.com
 
  


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
linux crontab vs unix crontab ytd Linux - General 2 08-09-2009 05:07 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
man crontab(5) vs crontab(1) Canis Polaris Linux - Newbie 2 06-04-2008 04:03 PM
no crontab? MrSako Linux - Software 17 12-22-2006 10:33 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM


All times are GMT -5. The time now is 09:51 PM.

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