Browsed by
Category: Scripts / Coding

Automatic WordPress Update Script

Automatic WordPress Update Script

Instal WP CLI on the server the WordPress is hosted on : https://wp-cli.org/#installing

Setup an update script using WP CLI commands:

#! /usr/bin/env bash
# Update all WordPress Plugins
wp plugin update --all
# Update all WordPress Translations
wp language core update
# Update WordPress Core
wp core update
# Update WordPress Database
wp core update-db
# Check no plugins need to be updated after core wordpress update. 
wp plugin update --all

Setup a scheduled task in linux crontab to run the script

0 4 * * *      user    /path/to/task/wpupdates.sh >> /path/to/logs/wordpress-$(date +\%d-\%m-\%Y).log 2>&1

Troubleshooting

Make sure that the user is the same as the folder owner

Make sure that the script is executable.