#1  
Old 18th April 2011, 17:38
bschultz bschultz is offline
Senior Member
 
Join Date: Jul 2006
Posts: 220
Thanks: 11
Thanked 10 Times in 10 Posts
Default PHP Script Via Cron

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!
Reply With Quote
Sponsored Links
  #2  
Old 19th April 2011, 00:50
bschultz bschultz is offline
Senior Member
 
Join Date: Jul 2006
Posts: 220
Thanks: 11
Thanked 10 Times in 10 Posts
 
Default

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!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron errors guimnk General 1 5th April 2011 09:20
ISPConfig3 Debian Squeeze Crontab - Log petrichbg Installation/Configuration 5 22nd March 2011 12:25
Problem with services!! banzaiwebstudio.com Installation/Configuration 7 19th May 2010 21:13
Unable to install ISPConfig bdonecker Installation/Configuration 21 26th May 2009 08:20
Apache2 Freezes celtic Server Operation 31 28th May 2007 17:18


All times are GMT +2. The time now is 09:25.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.