WordPress update monitoring

If you’re reading this, you know I rarely visit my blogs. That presents a problem, as I never get the nag from WordPress that my version is so out of date, my site has been taken over by Russian Yakuza using it to spy against the Chinese on behalf of Syria or something. Below is a simple little script that can be thrown in cron and will bug you when WordPress releases a new version and you’ve not updated.

DIRS="Insert list of directories with wordpress here"

for dir in $DIRS ; do
current_file=$dir/wordpress/wp-includes/version.php
if [ -f $current_file ] ; then
current=`grep ^\\$wp_version $current_file | awk '{print $NF}' | sed s/\;//g | sed s/\'//g`
survey_says=`wget -O - -o /dev/null http://api.wordpress.org/core/version-check/1.0/?version=$current`
if [ $survey_says != "latest" ] ; then
echo "$dir Needs an upgrade!!!!"
echo "Currently $current"
fi
else
echo "$current_file does not exist!"
fi
done

The key here is the URL “http://api.wordpress.org/core/version-check/1.0/?version=”. Append a version number to the end of that, and it will tell you if you’re at the latest or need to upgrade.

Leave a Reply