Dynamic crontab entry for day and night

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Dynamic crontab entry for day and night
# 1  
Old 04-28-2017
Dynamic crontab entry for day and night

I have query apply crontab entry that the script executes as below


day hours (before 8:00 PM and after 7:00 AM) execute every 5 min

in Night hours (after 8:00 PM to 7:00 AM) executes every 15 min

How can we set such entry in crontab ?
# 2  
Old 04-28-2017
Quote:
Originally Posted by kaushik02018
I have query apply crontab entry that the script executes as below


day hours (before 8:00 PM and after 7:00 AM) execute every 5 min

in Night hours (after 8:00 PM to 7:00 AM) executes every 15 min

How can we set such entry in crontab ?
Create two crontab entries to run the same script. One for day hours and one for night hours...
Code:
0,5,10,15,20,25,30,35,40,45,50,55 7-19 * * * script_to_execute
0,15,30,45 0-6,20-23 * * * script_to_execute

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 04-28-2017
You can do it in two ways: either use two crontab entries, or run the script every 5 mins, and in the script check for "night time" and skip (exit) two out of three runs.
This User Gave Thanks to RudiC For This Post:
# 4  
Old 04-28-2017
using in single script is good logic bit a complex as you have to keep history of Last two execution
# 5  
Old 04-29-2017
Not necessarily - check minutes and divide by three or use the mod function, respective ly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simpler crontab entry to execute pgm on last day of the month

The following bash command line works for the last day of the month. Test by replacing the 1 with tomorrows day of month number && echo "Day before tomorrow"Can it be used within crontab? As * * 28-31 * * && echo "Today ls last day of month" >>/tmp/crontabtestI tried to test crontab with... (1 Reply)
Discussion started by: lsatenstein
1 Replies

2. Shell Programming and Scripting

Crontab to skip only one entry in a day???

Hello Friends, I have a cron tab like this: 10,40 1-23 * * * /script i want to skip only one execution at 00:10, so basically i want it to execute every hour at 10th and 40th minute, except 00:10. Could anyone help me doing this Thanks folks :b: (4 Replies)
Discussion started by: Prateek007
4 Replies

3. Solaris

crontab entry

hi i am new in solaris. i am accessing server through putty. i could not add entry in crontab. i have given "crontab -e" for add a new entry. It is not coming. what parameter i have to set for getting crontab -e thanks (1 Reply)
Discussion started by: sunnybee
1 Replies

4. UNIX for Dummies Questions & Answers

Crontab entry

What should be the crontab entry for a script: to run at 3:00 AM EST Sun, Mon, Tue, Wed, Thu, Fri (3 Replies)
Discussion started by: proactiveaditya
3 Replies

5. Solaris

crontab entry

Hi, i need to setup a cronjob that has will execute iostat command from morning to evening time. for instance the timing has will be like this. 8:00 A.M -- 6:00P.M how to define this entry in crontab Regards (3 Replies)
Discussion started by: jaweedak
3 Replies

6. Solaris

crontab entry

How to set the crontab entry for every other Friday? Regards, Raj (1 Reply)
Discussion started by: rajip23
1 Replies

7. AIX

crontab entry

Hi. I'm new to AIX and I need to create a crontab entry to run a script every first 5 business days of the month? please help. (2 Replies)
Discussion started by: udelalv
2 Replies

8. Shell Programming and Scripting

crontab entry to run every last day of the month

i've created a script which should run every last day of the month. what would be the exact crontab entry for this? thanks! (9 Replies)
Discussion started by: tads98
9 Replies

9. Shell Programming and Scripting

Crontab Entry

Hi Everyone , have a nice day given below is the line i have added in crontab * * * * * /Rauf/script2.sh intended to run this script after every minute , when i run this script manually it runs fine and produces output , but after adding it to crontab ( like given above ) , it doesnt work ... (5 Replies)
Discussion started by: Dastard
5 Replies

10. UNIX for Advanced & Expert Users

crontab entry

Sometimes cron really upsets me and I cant figure out these types of wierd dates, but how do I get cron to run something on every other sunday? I am running Solaris 8. -S (4 Replies)
Discussion started by: Sowser
4 Replies
Login or Register to Ask a Question