Use cronjob in linux to regularly execute php scripts.
Enter commands in linux
crontab -e
Then, use the vim command to edit the opened file and enter
0 * * * * /usr/bin/php -f /home/userxxx/update.php
Save and exit. Now, the system will automatically execute the update. php script at each time. The script can be used to write database execution, automatic mail, and other functions.
Note: Writing 0 *** php-f/home/userxxx/update. php does not work.
In addition, the cronjob format 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 indicates Sunday) |
CMD |
Command |
Any command to be executed. |
Use (-) to define the scope
For example, 0 0-6 *** command indicates that the command is executed at every day.
Use (,) to enumerate the time
For example, "0, 15, 30, 45 *** command" indicates that the command is executed at, and each hour.
Use (/) to specify the interval
For example, **/4 ** command indicates that the command is executed every four hours.
Combination
0-10/2 *** command indicates that the command is executed every two minutes in the first 10 minutes.