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 02-28-2011, 09:58 AM   #1
vivekanandan
LQ Newbie
 
Registered: Apr 2008
Posts: 6

Rep: Reputation: 0
Cron job please help


My plan is to create a cron job that runs a script every 10 mins from 8 am to 9 pm and all days except Sunday to achieve this I put a crontab entry as given below

*/10 8-21 * * 1-6 /bin/sh /root/operations.sh

the job is running every 10 min but it is running round the clock not in between hrs 8 to 21. Please correct me where I am wrong.

Thanks

Regards
Vivek
 
Old 02-28-2011, 10:13 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
I would remove the /bin/sh from the command portion of the record. Alternatively you could put quotes around /bin/sh /root/operations.sh. The operations.sh script should already have the shell name in the first line so you should not need to specify the shell name when you run the script.
Code:
#!/bin/sh
Also, the cron job will start the script using the default shell of the user account under which it runs. This means that there are already two mechanisms in place to specify the shell that will run the script so you do not need to precede the name of the script with the name of the shell.

Unfortunately you will have to wait until 10:00 p.m. to see if any changes are effective.

Last edited by stress_junkie; 02-28-2011 at 10:18 AM.
 
1 members found this post helpful.
Old 02-28-2011, 11:31 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by vivekanandan View Post
the job is running every 10 min but it is running round the clock not in between hrs 8 to 21.
Actually it runs every 10 minutes from 8:00 to 21:50. To run from 8:00 to 20:50 the crontab entry should be:
Code:
*/10 8-20 * * 1-6 blah blah blah
If in addition you want to run at 21:00, I'm afraid you have to put a check inside the script itself (using your original entry) or add a new crontab entry like this:
Code:
0 21 * * 1-6 blah blah blah
 
1 members found this post helpful.
Old 03-02-2011, 04:28 AM   #4
vivekanandan
LQ Newbie
 
Registered: Apr 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you stress junkie and coluix

stress your replay "Unfortunately you will have to wait until 10:00 p.m" gave me in sight of cron job. and coluix your replay "Actually it runs every 10 minutes from 8:00 to 21:50" explained the cron job timing. what I am thinking is the cron job will stop by 9.00 pm. Yesterday i extended my shift timing and found that your all are correct.

Thank you so much.
 
  


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 cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 09:52 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
Cron job help tejama Linux - Newbie 16 11-09-2007 02:08 PM
cron job sanjith11 Linux - General 5 07-14-2004 02:06 PM
Cron Job imanahmadi Linux - Newbie 1 07-04-2003 12:39 AM


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