Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the syntax for a cron job that runs 15 and 45 minutes after the hour?

Tags:

cron

crontab

What is the syntax for a cron job that runs 15 and 45 minutes after the hour? (So every 30 minutes.)

Would the syntax be something like:

15,45,30   *       *       *       *       wget -O /dev/null http://somesite.com/4_leads.php

So for example it would run at

2:15
2:45
3:15
3:45
4:15
4:45

and so on

like image 940
Matt Elhotiby Avatar asked Oct 25 '11 18:10

Matt Elhotiby


People also ask

How do I run a cron job every 20 minutes?

For example, if you have 1-10/2 in the Minutes field, it means the action will be performed every two minutes in range 1-10, same as specifying 1,3,5,7,9 . Instead of a range of values, you can also use the asterisk operator. To specify a job to be run every 20 minutes, you can use “*/20”.

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.


1 Answers

From man 5 crontab

field          allowed values
-----          --------------
minute         0-59
hour           0-23
day of month   1-31
month          1-12 (or names, see below)
day of week    0-7 (0 or 7 is Sun, or use names)

Or, in other words

# m   h   dom mon dow   user          command
15,45 *    *   *   *    yourusername  wget -O /dev/null http://somesite.com/4_leads.php

Skip the username field if you place the entry in a user specific crontab, via crontab -e, crontab -e -u yourusername, or similar.

This question may be better suited to serverfault.

like image 76
Marty Avatar answered Oct 10 '22 17:10

Marty