#!/bin/bash
# === Configuration ===
WP_PATH="/var/www/html" # Path to your WordPress install
# === Navigate to the WP install directory ===
cd "$WP_PATH" || { echo "❌ Error: WP path not found"; exit 1; }
# === Update core ===
echo "⬆️ Updating WordPress core..."
wp core update
# === Update plugins ===
echo "🔌 Updating plugins..."
wp plugin update --all
# === Update themes ===
echo "🎨 Updating themes..."
wp theme update --all
# === Done ===
echo "✅ All updates complete."
How to Create and Execute This Script
Follow these steps to create and run your WordPress script:
Open Your Terminal
Connect to your server via SSH or open your local terminal.
Create the Script File
Use a text editor like nano to create a new file. For example:
$ nano my-script.sh
Paste the Script Code
Copy the full script from above and paste it into the terminal. Once done:
- Press CTRL+O to save
- Press Enter to confirm the filename
- Press CTRL+X to exit nano
Make the Script Executable
$ chmod +x my-script.sh
Run the Script
$ ./my-script.sh
⚠️ Backup First!
Use our handy script to run a full backup prior to using this script.
Requirements
- WP-CLI must be installed and accessible from the shell.
- wp-config.php must be correctly configured (WP-CLI uses it to access the DB).
- Run this script as a user with permission to access the WP directory and write to the backup folder.