• Centos定时执行python脚本


     其实就是linux的定时任务。老记不住参数,这次写下来,省着老百度。本文没有技术含量,请大家不要吐槽。   

    ================================================================

    每天清晨 4:00:01,用python执行/opt/aa.py文件。

    编辑定时任务:

    #crontab -e 

    加入:

    0 4 * * * python /opt/aa.py

    保存,退出即可。

     ================================================================

    crontab命令格式:

    * * * * * command
    M H D m d command

    M: 分(0-59) 
    H:时(0-23)
    D:天(1-31)
    m: 月(1-12)
    d: 周(0-6) 0为星期日


    * 代表取值范围内的数字
    / 代表"每"
    - 代表从某个数字到某个数字
    , 代表离散的取值(取值的列表)

    示例:

    ■每分钟执行:

    * * * * * date>>/opt/test.log

    相当于

    */1 * * * * date>>/opt/test.log

    注意,每分钟的意思是指,每分钟的第1秒开始执行。

    打开test.log文件就会发现结果:Sat Oct 12 14:25:01 CST 2013

    ■每4小时执行:

    * */4 * * * date>>/opt/test.log

    ■每周日执行:

    * * * * 0 date>>/opt/test.log

    ■每周六、周日执行:

    * * * * 6,0 date>>/opt/test.log

    ■每小时的第5分钟执行:

    5 * * * * date>>/opt/test.log

    很简单,只要记好位置和代表意义就行。

     参考地址

  • 相关阅读:
    Mybatis与Spring集成
    Mybatis 多对多
    Mybatis表关联多对一
    Mybatis表关联一对多
    Mybatis增删改查(CURD)
    Mybatis接口注解
    MyBatis环境配置及入门
    MyBatis教程
    Spring JDBC StoredProcedure类示例
    Spring JDBC SqlUpdate类示例
  • 原文地址:https://www.cnblogs.com/zhangwei595806165/p/4834185.html
Copyright © 2020-2023  润新知