您的位置:首页 > 其它

计划任务crontab

2015-03-03 14:03 260 查看
参考:

  http://blog.csdn.net/xrt95050/article/details/3980567

  http://www.cnblogs.com/zhenmingliu/archive/2012/04/27/2472958.html

服务名称:crond

查看服务状态示例:

service crond status
systemctl status crond    #CentOS 7


设置方法:

  1.命令行运行:crontab -e

  2.命令行运行:vim /etc/crontab 添加内容

    示例:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root                            

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

45 */1 * * * root /usr/local/bin/sshpass -p "abcdefg" ssh -p2222 ghost@123.123.123.123  #每小时的第45分钟以root用户ssh登录主机123.123.123.123


若要关闭邮件通知:

45 */1 * * * root /usr/local/bin/sshpass -p "abcdefg" ssh -p2222 ghost@123.123.123.123 >/dev/null 2>&1


PS

  手动删除/var/log/secure的内容后,需要重启日志服务:service rsyslog restart #CentOS下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: