2

I use this command to find and run all istances of wp-cron.php I have for each site I have:

find /var/www/ -name 'wp-cron.php' -exec php -q "{}" \;

Since my websites tree is:

/var/www/site1/htdocs/WORDPRESS-FILES
/var/www/site2/htdocs/WORDPRESS-FILES
/var/www/site3/htdocs/WORDPRESS-FILES
/var/www/site4/htdocs/WORDPRESS-FILES

... I'd like to limit my command to just 3 or 4 levels inside /var/www/ to avoid wasting resources and time! How can I do that?

I'm on Ubuntu 14.10.

1
  • 2
    With Gnu find: -maxdepth...
    – jasonwryan
    Apr 6 '15 at 1:36
3

If your find command has the -maxdepth option (Linux (GNU or BusyBox), FreeBSD, NetBSD, OSX):

find /var/www -maxdepth 3 -name wp-cron.php -exec php -q "{}" \;

If you want to run wp-cron.php files at an exact depth, you can use wildcards:

for x in /var/www/*/*/wp-cron.php; do
  php -q wp-cron.php
done

You can run

locate wp-cron.php

to quickly list all the files called wp-cron.php that existed the last time the locate database was updated (typically nightly).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.