Enter commands in linux
The code is as follows:
Then use the vim command to edit the open file and enter
The code is as follows:
Save, exit, okay, now the system will automatically execute the update.php script at every 0 o'clock. In the script, you can write functions such as database execution and automatic email sending.
Note: Directly writing 0 * * * * php -f /home/userxxx/update.php will not work.
In addition, the format of cronjob is:
MIN HOUR DOM MON DOW CMD
Field | Description | Allowed Value |
---|---|---|
MIN | Minute field | 0 to 59 |
HOUR | Hour field | 0 to 23 |
DOM | Day of Month | 1-31 |
MON | Month field | 1-12 |
DOW | Day Of Week | 0-6(0表示星期天) |
CMD | Command | Any command to be executed. |
Use (-) to delimit the range
For example: 0 0-6 * * * command means executing command
from 0-6 o'clock every dayUse (,) to enumerate time
For example: 0,15,30,45 * * * * command means that command will be executed at 0 minutes, 15 minutes, 45 minutes and 30 minutes of each hour
Use (/) to specify the interval
For example: * */4 * * * command means executing command every four hours
Combined usage
0-10/2 * * * * command means executing command
every 2 minutes in the first 10 minutes