找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 65|回复: 0

[文章] shell脚本无线循环

[复制链接]

86

主题

84

回帖

728

积分

管理员

积分
728
发表于 2023-10-19 11:06:42 | 显示全部楼层 |阅读模式
本帖最后由 aloneship 于 2023-10-19 11:41 编辑


#!/bin/sh

#kill相关的shell任务
#ps aux | grep '/data/shelltxt/bt_shell.sh' | awk '{print $2}'| xargs kill -9


#程序目录
www_path=/www/wwwroot/oa-api.beituan.work/

#命令集合
command_list=(insertTableData linkeOrderImport updateOrderInfoByDay exportHnOrder updateOrderInfoFromNopay analysisThird dealLocalExcelOrder)

#开始执行,先到screen里,再执行shell
while true
do
    #循环执行
    for command in ${command_list
  • }
            do
                pid=`ps -ef | grep "php artisan hnTaskCommand:test $command" | grep -v grep | awk '{print $2}'`
                if [ ! -n "$pid" ]; then
                    cd $www_path
                    /usr/local/php7/bin/php artisan hnTaskCommand:test $command
                    echo $command
                else
                    echo $pid
                fi

            done


        #轮询时间间隔
        sleep 1
    done

  • 您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-12-6 12:37 , Processed in 0.087186 second(s), 19 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表