Cron

From ShoutIRC RadioBot Wiki
Jump to navigation Jump to search

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`