Skip to content

Instantly share code, notes, and snippets.

@mattrude
Created January 3, 2014 06:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattrude/8233586 to your computer and use it in GitHub Desktop.
Save mattrude/8233586 to your computer and use it in GitHub Desktop.
A bash script to continuously run the runJobs.php script in small batches to allow a slow server to keep up and still allow public traffic on the site. This script should be placed in the mediawiki maintenance directory.
# Run meny MediaWiki Jobs
while [ `php showJobs.php` != 0 ];
do
echo -n "Starting over; `php showJobs.php` jobs left to run; running 10 jobs in 2 cycles."
php runJobs.php --maxjobs 10 --procs 5 --quiet
LOAD="`uptime |awk '{ print $10 }' |sed 's/,//g'`"
if [ $LOAD > 1.9 ]; then
WAIT=`echo "sqrt(2 * $LOAD * 50)" |bc`
echo " - Sleeping for $WAIT secs"
sleep $WAIT
else
echo " - Not sleeping"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment