Problem:
For some reasons i was not able to run the script having file handling functions from crontab, after few experiments on how to run the php script having file handling functions as cron job, have come up with the solution.


script.php
<?php

$fp = fopen(‘expireddaterange.txt’, ‘r’);
$file = file_get_contents(‘expireddaterange.txt’);

if(strlen($file) > 0){
….
}else{
echo ‘File[expireddaterange.txt] is Empty’;
exit;
}
?>
expireddaterange.txt contains:
20120206000000,20120221000000

when i run the php script from terminal

[root@xxxx ]# php script.php
the script executed porperly, but when the same script made as cron job entry,

[root@xxxx ]# crontab -e
35 14 * * * /usr/bin/php -d include_path=.:/full path of the script/script.php

And when the script, script.php executed at 2:35 pm, the script was throwing message  ”File[expireddaterange.txt] is Empty”, ie., cursor has fall in else part,

Solution:
For this to work, i made changes in the script.php
<?php

$fp = fopen(‘/full path/expireddaterange.txt’, ‘r’, true);
$file = file_get_contents(‘/full path/expireddaterange.txt’, true);
if(strlen($file) > 0){

….
}else{
echo ‘File[expireddaterange.txt] is Empty’;
exit;
}
?>

give permission to the file expireddaterange.txt

[root@xxxx ]# chmod 666 /full path/expireddaterange.txt

And the next time the crontab entry

35 14 * * * /usr/bin/php -d include_path=.:/full path of the script/script.php

will work.

Buy Levitra Oral Jelly without a prescription