Skip to content

Instantly share code, notes, and snippets.

@mtyeh411
Last active December 20, 2015 10:39
Show Gist options
  • Save mtyeh411/6117029 to your computer and use it in GitHub Desktop.
Save mtyeh411/6117029 to your computer and use it in GitHub Desktop.
cron this for a sane MediaWiki job runner
#!/usr/bin/env bash
WIKI_DIR="/var/www/html/w"
LOG_DIR="/var/log/wiki"
PIDDIR="/var/run/wiki"
mkdir -p $PIDDIR
JOBS=( "refreshLinks" "refreshLinks2" "SMWUpdateJob" "replaceText" "htmlCacheUpdate" "spsCreatePage" )
MAXJOBS=10
for JOBNAME in "${JOBS[@]}"
do
PIDFILE="$PIDDIR/$JOBNAME.pid"
if [ -e "${PIDFILE}" ] && (ps -u $USER -f | grep "[ ]$(cat ${PIDFILE})[ ]"); then
echo "Already running."
exit 99
fi
nice -n -5 php -f $WIKI_DIR/maintenance/runJobs.php - --maxjobs $MAXJOBS --type $JOBNAME >> $LOG_DIR/$JOBNAME.log &
echo $! > "${PIDFILE}"
chmod 644 "${PIDFILE}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment