How to make sure an application keeps running on Linux

前端 未结 16 1231
清歌不尽
清歌不尽 2020-11-28 18:51

I\'m trying to ensure a script remains running on a development server. It collates stats and provides a web service so it\'s supposed to persist, yet a few times a day, it

16条回答
  •  有刺的猬
    2020-11-28 19:28

    It's even simplier:

    #!/bin/bash
    
    export DISPLAY=:0
    
    process=processname
    makerun="/usr/bin/processname"
    
    if ! pgrep $process > /dev/null
    then
        $makerun &
    fi
    

    You have to remember though to make sure processname is unique.

提交回复
热议问题