• Crond服务+Shell实现秒级任务


    服务

    [root@19-v1-centos-6 ~]# chkconfig --list | grep crond
    crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
    

    查看任务

    [root@19-v1-centos-6 ~]# crontab -l
    */1 * * * * sh /server/scripts/task_start.sh
    

    编辑任务

    [root@19-v1-centos-6 ~]# crontab -e
    
    

    Shell 脚本

    [root@19-v1-centos-6 ~]# mkdir -p /server/scripts/
    [root@19-v1-centos-6 ~]# mkdir -p /server/logs/
    
    

    脚本内容

    #! /bin/bash
    task_url=("http://192.168.32.1/task.php/task/check_order" "http://192.168.32.1/task.php/task/check_robot_online")
    for n in `seq 10`
    do
         for task in ${task_url[*]}
         do
            curl $task  >> /server/logs/task.log
         done
         sleep 6
    done
    

    这个脚本其实就是已秒级去请求shell,如果shell去做后台运行加&,可能会死掉,重启也没有了,but crond最低是分级别的任务,所以crond+shell实现秒就很简单了。

     


    作者:Godtoy
    链接:https://www.jianshu.com/p/2dcda651c94d
    来源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
  • 相关阅读:
    Hive Word count
    Hive drop table batched
    BendFord's law's Chi square test
    Hive UDF 实验1
    java charset detector
    java Annotation Demo
    Reducejoin sample
    java Memorymapfile demo
    java :hello world
    Java dynamical proxy demo
  • 原文地址:https://www.cnblogs.com/gongxianjin/p/11266072.html
Copyright © 2020-2023  润新知