CentOS7 定时任务操作
CentOS7 定时任务 在计算机的使用过程中,经常会有一些计划中的任务需要在将来的某个时间执行,linux中提供了一些方法来设定 定时任务 。 1、 at 命令 at 从文件或标准输入中读取命令并在将来的一个时间执行,只执行一次。 at 的正常执行需要有守护进程 atd (关于systemctl请看 这一篇 ): #安装at yum install -y at 或 apt-get install at -y #启动守护进程 service atd start 或 systemctl start atd #查看是否开机启动 chkconfig -- list|grep atd 或 systemctl list-unit-files|grep atd #设置开机启动 chkconfig --level 235 atd on 或 systemctl enable atd 如果不使用管道 | 或指定选项 -f 的话, at 的执行将会是交互式的,需要在at的提示符下输入命令: [ root@centos7 temp] # at now +2 minutes #执行at并指定执行时刻为现在时间的后两分钟 at> echo hello world > /root/temp/file #手动输入命令并回车 at> <EOT> #ctrl+d 结束输入 job 9 at Thu Dec 22