Last active
December 20, 2015 10:39
-
-
Save mtyeh411/6117029 to your computer and use it in GitHub Desktop.
cron this for a sane MediaWiki job runner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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