First, the preface
The crontab command is common in UNIX and unix-based operating systems, and is used to set periodically executed instructions. This command reads the instruction from the standard input device and stores it in a user-named file in the "crontab" file (/var/spool/cron/
for later reading and execution. The word derives from the Greek chronos (χρνο), which is intended to be time.
Typically, crontab stored instructions are run in the background by daemon-crond activation, checking every minute for scheduled jobs to be performed. This type of assignment is commonly referred to as cron jobs.
Ii. initiation of the Crond process
If not installed, please install first:
Yum install Vixie-cron
yum install Crontabs
Third, crontab common orders:
crontab -e
edit crontab file, edit Crond process automatically read
crontab -l
list Details of user crontab files
crontab -r
Delete crontab file
Four, crontab file format
The crontab file is made up of 6 parts
1, minute one hour in which minute [0-59]
2. Which hour of hour day [0-23]
3. Which day of the Day-of-month January [1-31]
4, month-of-year of the year of January [1-12]
5, Day-of-week One day of the week [0-6]
6, commands to execute the order
None of these options is empty, and you can use * to represent any time if the user does not need to make several of them.
You can specify multiple values per time field, separated by commas, 5-8 */5
As indicated above, perform the scheduled task 3:15 every Monday to week 5.
Five, which users can use the crontab command
/etc/cron.allow
If this file exists, only users in this file can use the crontab command, and if the file does not exist, find/etc/cron.deny
/etc/cron.deny
If this file exists, the crontab command is not available to users in this file
If 2 files do not exist, only root can use the crontab command
If all 2 files exist and are empty, all users can use the crontab command
Six, timing tasks combined with PHP
Timing PHP is easy, just replace the command with a PHP script, which means that the index.php is executed every 1 minutes.
*/1 * * * * php/usr/www/test/index.php
Vii. Summary
The above is about Linux time task crontab all the content, we have learned it? I hope this article will help you learn or use Linux, thank you for your support to the cloud-dwelling community.