shell bash scripts : check process existed or not, if not existed then restart it

Put below scripts in your ~/.bash_profile or ~/.bashrc
It will auto run "unison" process if not running yet
when you open a new bash shell every time.
Change the process name "unison" for your case. :)
auto_unison() {
    u=`ps aux | grep unison | grep -v grep | wc -l`
    if [ $u -eq 0 ]
    then
        unison > /dev/null 2>&1 &
    fi
}
auto_unison

Comments

Popular posts from this blog

react-native run-android : sun.security.provider.cert path.SunCertPathBuilderException : unable to find valid certification path to req uested target

react-native run-android : do not build/update modified code(App.js)

How to fix error : no module named sendgrid when try to use sendgrid python lib in PHP.