Skip to content

Instantly share code, notes, and snippets.

@ebta
Last active August 31, 2021 14:22
Show Gist options
  • Save ebta/55318a9679d6c0426d9ff90aeef5ad29 to your computer and use it in GitHub Desktop.
Save ebta/55318a9679d6c0426d9ff90aeef5ad29 to your computer and use it in GitHub Desktop.
Update worpress, plugins and theme using wp-cli from Cron
#!/bin/sh
# Simple script to update a WordPress install (core, plugins, themes and languages) using wp-cli.
# Usually we expect to run this from cron.
# Written by Kitson Consulting and released into the public domain.
if [ $# -ne 1 ]
then
echo "Usage: $0 </path/to/wordpress/install>" >&2
exit 1
fi
if [ ! -d "$1" ]
then
echo "$1 does not appear to be a directory. Exiting." >&2
exit 2
fi
if [ ! -f "$1"/wp-config.php ]
then
echo "$1/wp-config.php does not exist. Did you specify the path to a WordPress install?" >&2
exit 3
fi
wp core update --path="$1" --quiet
wp plugin update --all --path="$1" --quiet
wp theme update --all --path="$1" --quiet
wp language core update --path="$1" --quiet
wp language plugin update --all --path="$1" --quiet
wp language theme update --all --path="$1" --quiet
# Usage
# ./wp-update /path/to/wordpress/site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment