找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

例行性命令的建立

2009-12-20 13:49| 发布者: admin| 查看: 79| 评论: 0|原作者: 云天青



1.仅进行一次的工作任务分配at
必须启动负责任务分配的服务atd
相关文件:
/var/spool/at
/etc/at.allow
/etc/at.deny
if 存在/etc/at.allow then
只有在此文件中的用户才能使用at
else if 存在/etc/at.deny then
在此文件中的用户不能使用at,其它用户可以
else
只有root可以使用at
相关命令:
at 设置任务 [m]当at工作完成后,以电子邮件方式通知用户
[root@NS5 ~]# at 20:00
at> /bin/mail test -s "test"
at> test at job
at> .
at> 按ctrl d结束
job 1 at 2008-12-24 20:00
atq 查询任务
[root@NS5 ~]# atq
1 2008-12-24 20:00 a root
atrm 删除任务
[root@NS5 ~]# atrm 1
[root@NS5 ~]# atq
2.循环执行的例行性命令crontab
服务crond
用户的设置
相关文件:
/var/spool/cron
/var/log/cron
/etc/cron.allow
/etc/cron.deny
相关命令:
crontab
-u 帮其他用户建立/删除crontab
-e 编辑crontab的工作内容
-l 查看crontab的工作内容
-r 删除全部crontab的工作
编辑格式:
分 时 日 月 周 命令串
[root@NS5 ~]# crontab -e
*/5 * * * * /home/test.sh # 每5分钟执行一次/home/test.sh
[root@NS5 ~]# crontab -l
*/5 * * * * /home/test.sh
[root@NS5 ~]# crontab -r
[root@NS5 ~]# crontab -l
no crontab for root
系统的设置: /etc/crontab
/etc/crontab 支持两种执行命令的方式:
直接执行命令
01 * * * * test mail -s "testing" tei < /home/test.txt
目录规划
*/5 * * * * root run-parts /root/runcron









最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 03:30 , Processed in 0.206422 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部