cron expression
By modifying the cron expression, execute the script regularly
Learn the basic writing of cron expressions
1, cron 6-digit expression
From left to right
The first digit represents
seconds
, only numbers between0-59
are allowedThe second digit represents
minutes
, only numbers between0-59
are allowed, and60
is not allowedThe third digit represents
hour
, only numbers between0-23
are allowed, and24
is not allowed at 12 o'clock in the morningThe fourth digit represents
Day
, only numbers between1-31
are allowedThe fifth digit represents
month
, only numbers between1-12
are allowedThe sixth digit represents
week
, only numbers between0-7
are allowed,0
and7
both represent Sunday
- Cron 5-digit expression
From left to right
The first digit represents
minutes
, only numbers between0-59
are allowed, and60
is not allowedThe second digit stands for
hour
, only numbers between0-23
are allowed, and24
is not allowed at 12 o'clock in the morningThe third digit represents
Day
, only numbers between1-31
are allowedThe fourth digit represents
month
, only numbers between1-12
are allowedThe fifth digit represents
week
, only numbers between0-7
are allowed,0
and7
both represent Sunday
- Special characters
,
stands forand
, such as0 0,12,18 * * *
means `execute once every day at 0 o'clock, 12 o'clock, and 18 o'clock)*
stands forany value
, such as* * * * *
stands forexecute every minute
/
stands forevery
, such as10-20/5 * * * *
stands for the 10th-20th minute of every hour, which is executed every 5 minutes, namely the 10th minute, 15th minute, and 20th minute Minutes`- Special case: you can omit
/1
when you want to express that it will be executed every 1 minute
- Special case: you can omit
- Error demonstration
60 * * * * *
Ideal: Execute once every 60th second of every minute. Actual: Unable to execute. Reason:60
is not allowed in thesecond
bit. Correct expression:0 * * * * *
* 12-18 * * *
Ideal: It will be executed once every day from 12:18 to 0:00. Actual: It will be executed every 1 minute from 12 am to 18 am every day. Reason: The first place is*
. Correct expression:0 12-18 * * *
* 12-18 * * *
Reasons for listing: classic demonstration by group friends, collective blindness series
0 18-12 * * *
Ideal: It will be executed once every day from 18:00 to 12:00 the next day at the 0 minute. Actual: Unable to execute. Reason: The time scale cannot be crossed. Correct expression:0 18-23,0-12 * * *
*/90 * * * * *
Ideal: it will be executed every 90 seconds. Actual: It is executed every 60 seconds. Reason:Second
is only60
, when it is greater than60
, it will be calculated as60
. Correct expression: currently unable to do it, recommend the curve to save the country