Created
May 27, 2021 13:11
-
-
Save amityweb/60cf3c420bdbc5d6f20e43f2da144b83 to your computer and use it in GitHub Desktop.
Bash script to iterate through all Wordpress sites on RunCloud and run Wordpress Cron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Change directory to /home | |
cd /home | |
# Iterate through all users directories | |
for user in * ; do | |
# For every webapp under the user directory | |
# Count wp-config files to make sure its Wordpess | |
# If its Wordpress, then run the WP CLI Script, which calls wp-cron.php | |
for d in $user/webapps/* ; do | |
count_file=`ls -1 $d/wp-config.php 2>/dev/null | wc -l` | |
if [ "$count_file" != "0" ] | |
then | |
sudo -u $user -i -- /RunCloud/Packages/php74rc/bin/php /home/$d/wp-cron.php | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For testing, change:
for user in * ; do
to a single user directory you dont mind testing on:
for user in mytestsite ; do