Skip to content

Instantly share code, notes, and snippets.

@rbocchinfuso
Created September 10, 2015 15:17
Show Gist options
  • Save rbocchinfuso/46e128597e0e798f761c to your computer and use it in GitHub Desktop.
Save rbocchinfuso/46e128597e0e798f761c to your computer and use it in GitHub Desktop.
hubot keepalive script
#!/bin/bash
# Add to crontab
# */5 * * * * ~/hubotAlive.sh hubot
hubotName=$1
hubotPID=$(ps -aux | grep -w node | grep -w ${hubotName} | grep -v grep | awk '{print $2}')
echo "hubot PID: ${hubotPID}"
if [ -n "${hubotPID// }" ] ; then
echo "`date`: $hubotName service running, everything is fine"
else
echo "`date`: $hubotName service NOT running, starting service."
cd /home/hubot/${hubotName}/bin
/home/hubot/${hubotName}/bin/${hubotName}.sh start > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment