Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create cron statement to run for multiple hours

I need a cron statement to run for few hours eg 1-8 then 10-15. In this case will the following statement work,

0 1-8,10-15 * * *  

If not can anyone help me?

Thanks in advance, Gnik

like image 924
Rajaa Avatar asked May 30 '12 06:05

Rajaa


People also ask

What is the use of * * * * * In cron?

It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .

How do I schedule a script in crontab to run every 5 minutes?

basic 3. /usr/bin/vim. tiny 4. /bin/ed Choose 1-4 [1]: Make a new line at the bottom of this file and insert the following code. Of course, replace our example script with the command or script you wish to execute, but keep the */5 * * * * part as that is what tells cron to execute our job every 5 minutes.

Is crontab a 24 hour format?

Scheduling a Job For a Specific Time The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM. The time field uses 24 hours format.


1 Answers

You cannot, you can use either multiple values OR a range

0 1,2,3,4,5,6,7,8,10,11,12,13,14,15 * * *

Source:

Time tags are separated by spaces. Do not use spaces within a tag, this will confuse cron. All five tags must be present. They are a logical AND of each other. There is another space between the last time tag and the first command.

A time tag can be a wildcard "*", which means "all". It can be one value, several values, a range, or a fractional range.

like image 147
OmnipotentEntity Avatar answered Sep 20 '22 13:09

OmnipotentEntity