I'm getting an error in the syslog when trying to run a couple of php scripts via cron. Here's the error: Apr 18 09:39:01 rpbroadcasting /USR/SBIN/CRON[18388]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete) Apr 18 09:40:01 rpbroadcasting /USR/SBIN/CRON[18464]: (root) CMD (/usr/bin/php /var/www/sportstest.txt >> /dev/null 2>&1) Apr 18 09:40:01 rpbroadcasting /USR/SBIN/CRON[18463]: (CRON) error (grandchild #18464 failed with exit status 1) The scripts then do not run. Any ideas why? The scripts are located in the /var/www/ directory. They check to see if a file exists in the /home/user/ directory...and if not, download it, rename it (based on today's date) and place it in the /home/user directory (which is also that user's FTP directory. Here is the file in question: <?php date_default_timezone_set('US/Central'); $fullyear = date('Y'); $year = date('y'); $month = date('m'); $day = date('d'); $now = date('Y-m-d-h'); $hour = date('g'); $hourplus1 = date('g', strtotime("Now +1 hour")); $hourminus1 = date('g', strtotime("Now -1 hour")); $ampm = date('A'); $rename_date = date('mdg'); $nowis = date('m'); ///////end of time constants /////// ///////// start of sports ///////// $newsfile = "/home/rpbroadcasting/audio/S" . $rename_date . ".mp3"; //echo $newsfile; if (file_exists($newsfile)) { echo "The file $newsfile exists"; echo system('exit'); } else { chdir('/var/www/sports/'); echo system('cp /backup.mp3 /var/www/sports/backup.mp3'); $dir1 = '/var/www/sports/'; $mydir1 = opendir($dir1); while(false !== ($file1 = readdir($mydir1))) { if($file1 != "." && $file1 != "..") { chmod($dir1.$file1, 0777); if(is_dir($dir1.$file1)) { chdir('.'); destroy($dir1.$file1.'/'); rmdir($dir1.$file1) or DIE("couldn't delete $dir1$file1<br />"); } else unlink($dir1.$file1) or DIE("couldn't delete $dir1$file1<br />"); } } closedir($mydir1); echo system('wget http://domain.com/file.mp3'); $fh = fopen("/var/www/sports/flash.mp3", "r"); rename("/var/www/sports/flash.mp3", "/var/www/sports/flash-$now.mp3"); $copy1 = "'/var/www/sports/flash-$now.mp3' '/home/rpbroadcasting/audio/S$rename_date.mp3'"; echo system('cp '.escapeshellcmd($copy1)); echo system('exit'); } ///////// end of sports ///////// ?> Thanks!
Boy, do I feel stupid! I was having a hard time getting the file rename based on the date in shell...so I used a php script. But, I didn't change the name of the file in the crontab. It still said file.txt...instead of file.php Sorry!