Linux中crontab定时任务

linux下定时任务添加

crontab是linux系统自带的功能,用户可以将编写好的脚本文件添加进去进行定时执行

注意:crontab是以root角色执行的,所以如果出现“ xxx command not found”
则需要执行以下当前非root用户.bash_profile进行更新path变量,否则就将命令写成全路径去执行

基本格式 :
*  *  *  *  *  command
分   时  日   月   周   命令

1、写入定时任务信息(指定日志)
crontab -e */1 * * * * /home/ap/ssp/sbin/ssp.sh > /tmp/cron  2>&1  #注意脚本需要授权 chmod u+x  不需要重启服务
2、查看现有定时
crontab -l
3、删除所有定时
crontab -r
4、定时服务控制
/sbin/service crond start
/sbin/service crond stop
/sbin/service crond restart
/sbin/service crond status
posted @ 2015-03-03 22:01  W&L  阅读(317)  评论(0)    收藏  举报