zoukankan      html  css  js  c++  java
  • 计划任务crontab

    参考:

      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下

  • 相关阅读:
    变量
    注释 & 缩进
    【oracle】生成AWR报告
    【Linux】awk指令
    rhel7.0替换centos yum源
    如何在乌班图上配置java开发环境
    如何在乌版图系统添加拼音输入法!
    如何让虚拟机中乌版图系统变大?
    如何重置虚拟机的乌版图系统的密码?
    虚拟机三种网络模式配置
  • 原文地址:https://www.cnblogs.com/flowjacky/p/4310804.html
Copyright © 2011-2022 走看看