Cron: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
DIR=/home/radio/radiobot | DIR=/home/radio/radiobot | ||
PROCNAME=radiobot | PROCNAME=radiobot | ||
PID=`/sbin/pidof ${PROCNAME}` | PID=`/sbin/pidof ${PROCNAME}` | ||
if [ "$PID" = "" ]; then | if [ "$PID" = "" ]; then | ||
echo "Running ${PROCNAME}..." | echo "Running ${PROCNAME}..." | ||
cd ${DIR} | |||
if [ "$DISPLAY" = "" ]; then | if [ "$DISPLAY" = "" ]; then | ||
./${PROCNAME} & | ./${PROCNAME} & | ||
Latest revision as of 00:35, 9 November 2015
One easy way to make sure you bot is always running on Linux/*BSD is to create a cron job.
Here is an example cron script to keep the bot running:
#!/bin/bash
# Edit these 2 lines for your RadioBot folder and executable name
DIR=/home/radio/radiobot
PROCNAME=radiobot
PID=`/sbin/pidof ${PROCNAME}`
if [ "$PID" = "" ]; then
echo "Running ${PROCNAME}..."
cd ${DIR}
if [ "$DISPLAY" = "" ]; then
./${PROCNAME} &
else
./${PROCNAME}
fi
fi
If your system doesn't have pidof, you could also replace the PID=... line with this:
PID=`ps ux | grep ${PROCNAME} | grep -v grep`