LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-12-2010, 06:36 AM   #1
sudhirav
LQ Newbie
 
Registered: Aug 2010
Posts: 9

Rep: Reputation: 0
Help with cronjob scheduling


Hi Everybody,

How to schedule a job using cron that shouldn't run between working hrs 9am-5pm, while run in non working hrs every hour, every day of the month, month & week.

I tried the following way, not sure I can use logical not operator(!). Please correct me if wrong or suggest other ways which might be better.

crontab -e
0 !9-17 * * * /path/to/script/file

I guess other way is
0 17-8 * * * /path/to/script/file

Thank you in advance
 
Old 08-12-2010, 07:54 AM   #2
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
i never use (!) in crontab.

in crontab 24hrs format so second way is better
 
Old 08-12-2010, 08:02 AM   #3
sudhirav
LQ Newbie
 
Registered: Aug 2010
Posts: 9

Original Poster
Rep: Reputation: 0
Hi Sem007,

Thanks for the reply, when we can use (!) in scripts why not use them in crontab also.
 
Old 08-12-2010, 09:24 AM   #4
tospo
LQ Newbie
 
Registered: Dec 2007
Posts: 17

Rep: Reputation: 0
you can't use ! but you can use ranges and lists, such as
Code:
0   0-9,17-23   *   *   *
which will run every full hour from midnight to 9am and then again from 5pm to 11pm.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cronjob..... milindpk Linux - Newbie 6 05-06-2010 06:52 PM
cronjob dnaqvi Linux - General 5 04-26-2010 04:05 AM
cronjob xser Linux - Software 6 07-27-2008 09:38 PM
Cronjob engnet Linux - Networking 6 03-03-2004 09:21 AM
cronjob ugob Linux - Software 0 03-03-2004 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:29 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
Open Source Consulting | Domain Registration