Bash:在不同文件夹中搜索具有相同名称的文件并执行它们

问题描述:

I'm trying to run every wp-cron.php included in my /var/www/ subdirs. I have multiple websites inside /var/www/, so I tried doing something like this:

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

But other files are executed, not related to wp-cron.php. What's wrong with the command above?

我正在尝试运行中包含的每个 wp-cron.php code> > / var / www / code> subdirs。 我在 / var / www / code>中有多个网站,所以我尝试这样做: p>

   find / var / www / -ipath * / wp-cron.php -exec php -q“{}”\; 
  code>  pre> 
 
 

但其他文件是 执行,与 wp-cron.php code>无关。 上面的命令出了什么问题? p> div>

Correct find command to find wp-corn.php is to use -iname or -name option:

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