ChatGPT解决这个技术问题 Extra ChatGPT

Run CRON job everyday at specific time

Right now i am running my cron job everyday at 3.00PM

0    15    *    *    *

But I want to run my cron job twice in a day. 10.30AM and 2.30PM

0    30 10    *    *    *

I believe this command will run at 10.30AM. How should i run it in 2.30PM?

please read this question stackoverflow.com/questions/13993556/…

R
Renjith V R

Cron utility is an effective way to schedule a routine background job at a specific time and/or day on an on-going basis.

Linux Crontab Format

MIN HOUR DOM MON DOW CMD

https://i.stack.imgur.com/b14Dw.png

Example::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.

Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.

30 08 10 06 * /home/yourname/full-backup

30 – 30th Minute

08 – 08 AM

10 – 10th Day

06 – 6th Month (June)

*– Every day of the week

In your case, for 2.30PM,

30 14 * * * YOURCMD

30 – 30th Minute 14 – 2PM *– Every day *– Every month *– Every day of the week

To know more about cron, visit this website.


wait but this is 1 time only right? isn't OP asking about 2 times
R
Roman Nakutnyi

From cron manual http://man7.org/linux/man-pages/man5/crontab.5.html:

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: "1,2,5,9", "0-4,8-12".

So in this case it would be:

30 10,14 * * *


This is the most effective solution. Following web site is good for verbally understanding the cron schedules. crontab.guru
M
Mohit Rathod

you can write multiple lines in case of different minutes, for example you want to run at 10:01 AM and 2:30 PM

1 10 * * * php -f /var/www/package/index.php controller function

30 14 * * * php -f /var/www/package/index.php controller function

but the following is the best solution for running cron multiple times in a day as minutes are same, you can mention hours like 10,30 .

30 10,14 * * * php -f /var/www/package/index.php controller function