Skip to content

Instantly share code, notes, and snippets.

@chmac
Forked from fcingolani/wp-cron.sh
Created May 2, 2012 10:49
Show Gist options
  • Save chmac/2575823 to your computer and use it in GitHub Desktop.
Save chmac/2575823 to your computer and use it in GitHub Desktop.
Bash Script to execute wp-cron.php on a Multisite Wordpress installation, extracting database info from wp-config.php.
#!/bin/bash
# Script inspired by https://gist.github.com/1025598
#### WARNING ####
#### Please be careful with this script. The use of eval $(find) is dangerous.
#### If a user can upload a file called wp-config.php anywhere onto your site,
#### they can probably execute arbitrary commands via this script.
#### You have been warned. GPL, no warranty.
# Inspired by http://stackoverflow.com/questions/7586995/read-variables-from-wp-config-php
eval $(find . -name "wp-config.php" -print0 | xargs -0 -r grep -e "DB_HOST" -e "DB_NAME" -e "DB_USER" -e "DB_PASSWORD" | awk -F"[()']" '/^define/{printf "%s=\"%s\"\n", $3, $5;}')
DOMAINS=$(mysql --silent --skip-column-names --host $DB_HOST --user $DB_USER -p$DB_PASSWORD $DB_NAME --execute "SELECT CONCAT(domain,path) FROM wp_blogs WHERE archived = '0' AND spam = '0' AND deleted = '0';")
for DOMAIN in $DOMAINS
do
wget --quiet --output-document=/dev/null http://$DOMAIN
sleep 2
done
@chmac
Copy link
Author

chmac commented May 2, 2012

Please be careful with this script. The use of eval $(find) is dangerous. If a user can upload a file called wp-config.php anywhere onto your site, they can probably execute arbitrary commands via this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment