Cron

From ShoutIRC RadioBot Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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`