Difference between revisions of "Cron"

From ShoutIRC RadioBot Wiki
Jump to navigation Jump to search
(No difference)

Revision as of 19:38, 28 October 2013

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

cd ${DIR}

PID=`/sbin/pidof ${PROCNAME}`
if [ "$PID" = "" ]; then
        echo "Running ${PROCNAME}..."
        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`