Use crontab command for timing tasks

Program name: cron
program package: cronie
command: crontab
installation package: crontabs
service/process name: crond

View the service status (centos7): systemctl status crond
View the service status (centos7): the name is all systemctl status crond.service

crontab -e edit timed tasks (the editing method is the same as vim, i insert, :wq save and exit)
crontab -l display the current timed tasks
crontab -r clear
* * * * * command
time division day month week
0~59 minutes, every minute Use * or */1 to indicate
0~23 o'clock,
1~31
January to December
0~6 weeks
* means all numbers in the range of value
/ means every, /5 means every five units
-means from several to several
, Represents the scattered number

You can put the script in the default task directory:
/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
For one-time tasks, you can use the at command

If you write the command directly in the command position, make sure that the command is executable separately. But it may also be executable separately but still make an error, you must write the command in the script.
Complex tasks are executed with scripts.

Guess you like

Origin blog.csdn.net/qq_43750882/article/details/110880845