#!/bin/sh # Check if bot is runing then exit otherwise restart # put in crontab # 0,10,20,30,40,50 * * * * /path/to/check.sh MYPATH=/path/to PID=0 if test -r $MYPATH/bot.pid; then PID=$(cat $MYPATH/bot.pid) fi if [ 0 -ne $PID ]; then running=`ps --pid $PID | grep $PID |wc -l` if [ $running -eq 1 ]; then exit 1 fi fi cd $MYPATH ./check.sh & >/dev/null
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Check if not running then start (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» backup multiple mysql databa... in email bash cron sql mysqldump
» Pretty PS1 Prompt for Bash in shell bash bashrc prompt
» Bash function to copy SSH DS... in ssh shell zsh bash
» How to flush the local DNS c... in lighttpd virtualhosting shell bash hosts dns cache
» Redirect all output to a sin... in shell bash logging
» Remove all but X most recent... in shell bash
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails