Linux思维导图之计划任务

版权声明:©2018 DuanXin. All Rights Reserved. https://blog.csdn.net/qq_42736877/article/details/82559978

查漏补缺,理解概念,及时总结,互相交流,欢迎拍砖。

  1. 用yum install -y vixie-cron这个命令进行安装计划任务服务,可以在安装之前使用crontab -e进行检测一下,服务器是否安装了这个服务!

  2. 安装之后呢,使用crontab -e 就可以添加我们的计划任务了,例子:

    */1 * * * * /usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

    每分钟执行以下Api 分组下面的offeredCoupon方法

    30 21 * * * /usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

    上面的例子表示每晚的21:30执行以下Api 分组下面的offeredCoupon方法

    45 4 1,10,22 * */usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

    上面的例子表示每月1、10、22日的4 : 45执行以下Api 分组下面的offeredCoupon方法

    10 1 * * 6,0 /usr/bin/curl -o temp.txt http://www.baidu.com/index.php/Api/Contab/offeredCoupon

    上面的例子表示每周六、周日的1 : 10执行以下Api 分组下面的offeredCoupon方法

    注意(下面是对上面的解释):

    *  *  *  *  *  command

    分 时  日  月  周  命令

    第1列表示分钟1~59 每分钟用*或者 */1表示

    第2列表示小时1~23(0表示0点)

    第3列表示日期1~31

    第4列表示月份1~12

    第5列标识号星期0~6(0表示星期天)

    第6列要运行的命令

  3. 编好文件之后,按ESC键,之后(:wq)保存退出

  4. service crond restart 重启计划任务

    以上就是Linux定时任务的配置方式,at用的较少,如游戏升级开服之类的临时用到,如有疑问可参考上图的知识图。

猜你喜欢

转载自blog.csdn.net/qq_42736877/article/details/82559978