My goal is to make a script that I can execute through a cron job.
The script needs to find several killstat.php files in multiple directories and execute them.
This is what I have so far:
#!/bin/bash NAMETOFIND=$(find /home/ -name "killstat.php") for i in $NAMETOFIND; do /usr/bin/php -f $i; done
killstat.php should be executed to reset my statistics. But it seems the php file is not executed. When I change the -f switch to -l (syntax error checking) the script executes fine!
php killstat.php from the CLI also works fine and resets the statistics.
I'm running as root and also killstat.php and my script are owned by root.
The script is chmod to 4755
Solution provided by Hastur with tiny alteration.
I place this script in /etc/cron.monthly to reset my statistics.
#!/bin/bash find /home -name "killstat.php" | while read i do Cdir=$(dirname "$i") Cname=$(basename "$i") # This line can be avoided.. cd "$Cdir" /usr/bin/php -f "$Cname"; # ...if here you use killstat.php  cd - done