If the task is to be executed periodically, use cron
If a task executes only once in a particular practice, use the at
[email protected] grub.d]# which shutdown
/usr/sbin/shutdown
[Email protected] grub.d]# at now + minutes #设置从现在开始30分钟后关机
At>/usr/sbin/shutdown-h Now
At> <EOT>
Job 4 at Mon Jul 30 16:54:00 2018
[Email protected] grub.d]# ATQ #查看任务列表
4 Mon Jul 16:54:00 2018 a root
[Email protected] grub.d]# ATRM 4 #删除定时任务
[Email protected] grub.d]# ATQ
[Email protected] grub.d]#
You can also define a detailed date time to execute
[[email protected] grub.d]$ at 01:00 2018-08-02
At>/usr/sbin/shutdown-h Now
At> <EOT>
Job 6 at Thu 2 01:00:00 2018
[Email protected] grub.d]$ ATQ
6 Thu 2 01:00:00 2018 a Liuyu
By default, everyone can use the AT command to dispatch their own tasks, and if you want to disable this feature for some users, add the user's username to/etc/at.deny.
When you execute cron, check to see if the Crond process is running
Users can set their own scheduled tasks through the crontab command, and the-e parameter to edit the task in B.
Format to execute the command
The first 5 good is to define the time, in order: minutes, the value 1-59, the hour, the value 0-23; date, value 1-31; month, value 1-12; Day of the week, value 0-6;
After setting the time, follow the command you want to execute.
You can use Crontab-l to view the set of tasks
You can delete all tasks by using Crontab-r
Each user can set their own scheduled tasks, if you want to prohibit a user, the user name is added to/etc/cron.deny
Root users can view other users ' scheduled tasks
Crontab-u zhangsan-l
View System routine Tasks/etc/crontab
[[Email protected] etc]# CD cron.
cron.d/cron.daily/cron.hourly/cron.monthly/cron.weekly/
Linux Routine Task management