#! /bin/bash while true do sleep 30m # If nothing has been written to the log for 30 minutes then we assume # pbot is dead. if [[ -z $(find logs/ -iname 'raw.log' -mmin -30) ]] then # Kill all pbot processes while read -r line do # If it's not the pid of this process then kill it. [[ "${line}" != "$$" ]] && kill "${line}" &>/dev/null done < <( pgrep -u pbot ) # Start pbot cd /home/pbot ./envbot & ./labs_change_detector & fi done