「学习笔记——Linux」Linux下如何在特定时间执行特定任务
Linux下如何在特定时间执行特定任务1 仅执行一次的任务2 循环执行的任务3 可唤醒停机期间的工作任务所需程序atd服务at命令启动atd# service atd restartatd stop/waitingatd start/running, process 11031
# service atd restartatd stop/waitingatd start/running, process 11031
千万注意要在root下执行,不然会提示Rejected send message.
at的使用使用at的权限(因为安全性考虑最好设置)在/etc/at.allow中设置可以使用at的账号在/etc/at.deny中设置不可以使用at的账号示例1分钟后执行mkdir$ at now + 1 minuteswarning: commands will be executed using /bin/shat> mkdir helloAtat> <EOT>job 1 at Wed Feb 6 14:36:00 2013查看工作
# at -c 2#!/bin/sh# atrun uid=0 gid=0# ...$ mkdir helloAt特定时间关机
$ at 14:00 2013-2-9warning: commands will be executed using /bin/shat> /bin/syncat> /bin/syncat> /sbin/shutdown -h nowat> <EOT>job 4 at Sat Feb 9 14:00:00 2013at如何执行输入输出:标准输入输出会重定向到mailbox里,所以执行echo "hello"在终端下是看不到的后台工作:系统会将at工作独立于shell,交给atd程序接管,即使关了shell也没关系查询与删除at中的工作查询:atq删除:atrm jobidbatch:和at相似,只是在cpu负载低时才执行