How to run cron entry every 5 min during office hours only?


 
Thread Tools Search this Thread
Operating Systems Solaris How to run cron entry every 5 min during office hours only?
# 1  
Old 12-21-2016
How to run cron entry every 5 min during office hours only?

Hi

I need to setuop a cron entry to run every 5 min, only in office hours (between 8:00AM to 18:00PM, I did the following:
Code:
0,5,10,15,20,25,30,35,40,45,50,55 8,9,10,11,12,13,14,15,16,17,18 * * * /home/xxx/zzz.ksh

But somehow does not work.
Could it be wrong?
# 2  
Old 12-21-2016
I reckon the hours field should be "8-17" so first run at 0800 and last at 1755.

Use a hypen to denote a range of hours.

---------- Post updated at 11:59 AM ---------- Previous update was at 11:54 AM ----------

Of course, that will run 7 days a week unless you specify a 'day of week' range instead of the *
This User Gave Thanks to hicksd8 For This Post:
# 3  
Old 12-21-2016
I have change now, waiting to see the results (my time in GMT +2)
# 4  
Old 12-21-2016
Some cron servers also accept this syntax:-
Code:
*/5 8-17 * * * /your/command/here

This is the step from the zero of that item, so should be a factor of the maximum, e.g. 2, 3, 4, 6 or 12 for the hours. I can't see a neat way to do it every 10 minutes replacing 5,15,25,35,45,55, although you could build it something like this:-
Code:
*/10 * * * * bash -c "/bin/sleep 300 ; /your/command/here"

The best place to check if your host supports it is the manual page for the file crontab.
Often this can be found with man 5 crontab but check with man -k crontab to get the various options for pages you can read, such as Unix.com man page for crontab file




I hope that this helps,
Robin

Last edited by rbatte1; 12-21-2016 at 09:05 AM.. Reason: Smartened URL display
This User Gave Thanks to rbatte1 For This Post:
# 5  
Old 12-21-2016
the
Code:
*/5 * * * * /your/command/here

does not work on solaris 10, only in linux
# 6  
Old 12-21-2016
Don't forget, you should be using the 'crontab' command to enter cron jobs. If you're editing the crontab file directly yourself then cron may not know about the changes for up to 24 hours and therefore the job(s) won't run. Otherwise restart the cron daemon from the command line to alert it of the changes.
This User Gave Thanks to hicksd8 For This Post:
# 7  
Old 12-21-2016
I've found this document that suggests that it has an extension to allow this:-
Code:
5/10 * * * * /you/command/here

.... but there is no clue which variant this might be deployed in. It is rejected for me on CentOS 6 with this:-
Code:
crontab: installing new crontab
"/tmp/crontab.cVRcNc":3: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit?

It might be useful, but I'd prefer a fully functional external scheduler that allows for structured job planning and dependencies unless it's simple jobs running on many and widely distributed servers. Horses for courses I suppose. Smilie


Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can anyone help me to print UNIX epoch time to days,hours,min,sec ?

I have unix epoch time 1441678454803, Can you please help me to print this time in below format ? DAY,HOUR,MIN,SEC Appreciate your help!!! Thanks, Prince (7 Replies)
Discussion started by: prince1987
7 Replies

2. UNIX for Dummies Questions & Answers

Cron every 5 min

Hi, I am trying to run a script in cron every 5 min in SOLARIS 10 When I do5 * * * * /path to fileor*/5 * * * * /path to file Doesn't work. Please let me know what should I put in the cron entry Thanks (2 Replies)
Discussion started by: Rossdba
2 Replies

3. UNIX for Dummies Questions & Answers

How to Disabling cron for few hours each day

Hi Is there any way to disable cron adhoc ? I want to run a script for every one minute between 04 to 00 hours will the below serves my purpose ? 01 04-00 * * * <your script> (1 Reply)
Discussion started by: rakeshkumar
1 Replies

4. HP-UX

Crontab do not run on PM hours

Hi All I have a problem, I wonder if you can help me sort it out: I have the following entry in the cron: 00 1,13 * * * /home/report/opn_amt_gestores_credito.ksh > opn_amt_gestores_credito.log But the entry only runs at 01:07 I have stopped the cron deamon, and started, but it still... (39 Replies)
Discussion started by: fretagi
39 Replies

5. AIX

cron off by 5 hours

stupid question im sure, but its frustrating My cron jobs are off by 5 hours. My system time is right but all of my cron jobs are running approximately 5 hours late. Any idea why? (4 Replies)
Discussion started by: mshilling
4 Replies

6. UNIX for Dummies Questions & Answers

Run a script if file modified in last 10 min

Hi, I want to check if a file is modified or not in the last 10 mins and run a script if so. Thanks (8 Replies)
Discussion started by: krabu
8 Replies

7. Solaris

User entry in both cron.allow and cron.deny

Hello All, Anybody please help me to know ,what happens when a user having entry in both cron.allow and cron.deny files.Wheather the user will be able to access the crontab??? Thanks in advance Vaisakh (5 Replies)
Discussion started by: ksvaisakh
5 Replies

8. Shell Programming and Scripting

Cron job for every five minutes and between hours

Hi I need to run a script every five minutes and it should run between 07-15 hours all days. How i can achieve this... i tried like this */5 07-15 * * * /scripts/CreateFtpData.sh It throws an error... (1 Reply)
Discussion started by: aemunathan
1 Replies

9. UNIX for Dummies Questions & Answers

cron job every 2 min

hi guys! I have problem with cron :rolleyes: 2,4,6,8,10,12,14,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60 * * * * /usr/local/george/update.py I try this to schedule the script to run every second min forever :cool: but it doesn't work :o any idea? thanks in... (4 Replies)
Discussion started by: georgeplus
4 Replies

10. Shell Programming and Scripting

Add data in days:hours:min:sec format

I want to add these no. these are in the format of days:hours:minutes:sec I want result in this format only 0:00:04:59 0:00:00:12 0:00:00:28 0:00:00:03 0:01:29:35 0:00:00:19 0:01:05:21 Is any body ca help me????? To get This.. Thanks Nishant (1 Reply)
Discussion started by: krishna_sicsr
1 Replies
Login or Register to Ask a Question