Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cronjob frequency

Posted on 2011-09-21
9
Medium Priority
?
740 Views
Last Modified: 2012-05-12
how to schedule a job via crontab to run every 15 minutes  excluding during the window starting midnight until 7am, at this h time we would like snapshots taken every 2 hours(midnight, 2, 4 and 6).
0
Comment
Question by:it-rex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 18

Expert Comment

by:liddler
ID: 36573841
not easily with standard cron, I would usually schedule a script to run every 15 minutes, the first part of the script would look at the time and exit gracefully if it was between 00 - 07 and not 2, 4 or 6
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36573861
00,15,30,45 7-23,1,3,5 * * * /path/to/script >/path/to/log 2>&1

If you want to run it at 0, 2, 4 and 6 A. M every 15 minutes except for the full hour add a second line:

15,30,45 0,2,4,6 * * *  /path/to/script >/path/to/log 2>&1


wmp
0
 
LVL 11

Author Comment

by:it-rex
ID: 36574037
so woolmilkporc

00,15,30,45 7-23,1,3,5 * * * /path/to/script >/path/to/log 2>&1

will do it for me;again I need  to run every 15 minutes starting 7 am till 11 pm and
every 2 hours starting midnight till 6 am
?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:user_n
ID: 36574045
crontab

UNIX systems have a deamon running all the time that can run jobs at regularly scheduled intervals. You can specify the jobs that the crontab command will execute in a file, and the cron deamon will check it when the cron deamon is initialized or when additions or modifications are made to the file.

The entries you can make in the crontab file consist of the following fields (separated by spaces or tab character):

    minute
    hour
    day (of the month)
    year
    day of the week
    command

Each of these fields can have more than one discrete value (separated by commas) or a range of values or an * (asterisk) meaning all values are to be matched.

Following is a list of flags that can be used with the crontab command:

    -l to list your crontab file.

    -e to edit or create the crontab file.

    -r to remove your crontab file.

    -v to list the status of the crontab jobs.

Examples If you want to display the string Time to go for lunch at 12:30 pm every day, set up the following:

30 12 * * * * echo "Time to go for lunch"

If you want to execute my_job on Friday at 4:00 p.m. every week, setup the following:

0 16 * * 5 my_job



from http://www.math.iitb.ac.in/resources/manuals/Unix_Unleashed/Vol_1/ch05.htm
0
 
LVL 9

Expert Comment

by:user_n
ID: 36574062
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36574074
With my version the script will run every 15 minutes at

7, 8, 9, 10, 11. 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 1, 3, 5 hours.

so:

7:00, 7:15, 7:30, 7:45, 8:00, 8:15, ..., ... 22:45, 23:00, 1:00, 1:15, 1:30, 1:45, 3:00, 3:15, 3:30, 3:45, 5:00, 5:15, 5:45, 7:00 ...

Is this what you desire?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36574094
Forgot some values:

23:15, 23:30, 23:45

Sorry.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 36574168
>> I need  to run every 15 minutes starting 7 am till 11 pm and every 2 hours starting midnight till 6 am <<

Or maybe you mean this:

00,15,30,45 7-23 * * * /path/to/script >/path/to/log 2>&1
00 0,2,4,6  * * * /path/to/script >/path/to/log 2>&1

This will run the script at

7:00, 7:15, 7:30, 7:45, 8:00, 8:15, ..., ..., 22:45, 23:00, 23:15, 23:30, 23:45, 0:00, 2:00,4:00, 6:00, 7:00, 7:15, ...
0
 
LVL 11

Author Closing Comment

by:it-rex
ID: 36574591
thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question