LinuxQuestions.org
Review your favorite Linux distribution.
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 03-08-2010, 10:34 AM   #1
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Rep: Reputation: 15
Exclamation Crontab question (Every few minutes after a certain time)


Hi all,

I am able to get a job to run every x amount of minutes but what I need is to be able to get thsi job to run every x amount of minutes after, say 9am on a certain day.

The only part I'm struggling with is the "after 9am" part. All the other things like day of week and the actual command all work perfectly.
 
Old 03-08-2010, 10:37 AM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
*/x 9-24 certain_day * * job
 
1 members found this post helpful.
Old 03-08-2010, 10:54 AM   #3
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Original Poster
Rep: Reputation: 15
So I have:

Code:
*/5 9-11 * * 5 command
That will execute the command every five minutes on Fridays?
 
Old 03-08-2010, 12:17 PM   #4
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Yes. Two hours between 09 and 11 am. 24 times.
 
Old 03-08-2010, 02:20 PM   #5
nuwen52
Member
 
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208

Rep: Reputation: 46
Actually, I ran a quick test on that because I wanted to know what would happen...

crontab entry:
Code:
*/5 11-12 * * * root /home/tests/test0.sh
test0.sh
Code:
#!/bin/sh
DATECODE=`date +%H:%M:%S`
echo $DATECODE >> /tmp/cron_junk.txt
output of cron_junk.txt:
Code:
...
11:50:01
11:55:01
12:00:01
12:05:01
12:10:02
12:15:01
...
12:55:01
As you can see, it actually went until (5 minutes before) 13:00 even though it was expected to end at 12:00. So, what it seems to be is that for every hour that starts with the number specified in the range, the command runs. So, I would expect that "*/5 9-11 * * 5 command" would run every 5 minutes until 12:00, which may not be the desired affect. (Unless I had done something incorrectly.)

Last edited by nuwen52; 03-08-2010 at 02:25 PM.
 
1 members found this post helpful.
Old 03-08-2010, 03:41 PM   #6
Norwood
Member
 
Registered: Feb 2010
Location: A Smidge South O' Boston
Distribution: Debian
Posts: 41

Original Poster
Rep: Reputation: 15
Gotcha, and that actually makes sense now that I think about it.

Man I love this place!
 
  


Reply

Tags
awesome, expert, helpful


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
How to start crontab every 5 minutes? cola Linux - General 15 12-31-2009 12:00 PM
ntp time 12 minutes slow GregLee Linux - Software 8 09-14-2009 12:22 PM
Crontab Time Differs From Server Time Through Date onesikgypo Linux - Newbie 2 06-08-2009 10:36 AM
Crontab time question thetawaverider Linux - Newbie 3 05-24-2007 11:30 PM
Crontab every 10 minutes Neorio Linux - General 1 11-19-2003 12:46 AM


All times are GMT -5. The time now is 06:34 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