linux - run the script every 30 minutes bash -


i want run script every 30 minutes cron have problem code. in every 30 min have kill old script , run again. have somethink this, not working:

    cd /var/www/scripts     pkill -f bot     now="$(date +%y%m%d%h%m%s)"     screen -s bot      node mybot.js >> logi/logi_$now.txt 

you may not use screen running things in background in script. use ampersand (&) background process , nohup won't killed when cron script exits. remember subprocess pid in file.

something this:

kill -- "$(cat mybot.pid)" now="$(date +%y%m%d%h%m%s)" nohup node mybot.js >> "logi/logi_$now.txt" & echo $! > mybot.pid 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -