linux脚本中防止杀掉当前进程
PHP中文网
PHP中文网 2017-04-17 15:29:40
0
2
449
PHP中文网
PHP中文网

认证0级讲师

reply all (2)
大家讲道理

1.cd ~/scripts/job.sh, what the hell is this? cd a file?
2. It is recommended not to write the script like this:
First determine whether the previous process exists. If it does not exist, execute the script directly

count=`ps -ef|grep job.sh|grep -v grep|wc -l`

Kill the process if present

ps -ef|grep job.sh|grep -v grep |awk -F ' ' '{print }'|xargs kill -9

3. Do not use killall, as this will kill the script you are currently starting, and of course subsequent commands will not be executed.

    迷茫

    When executing a task, you can write a lock. When the next repeated script is executed, it will be judged whether there is a lock. If there is no lock, it will be executed. If there is a lock, it will not be executed.

    If you just kill the previous mission, it will be in vain.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!