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.


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

if(strlen($file) > 0){
echo ‘File[expireddaterange.txt] is Empty';
expireddaterange.txt contains:

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,

For this to work, i made changes in the script.php

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

echo ‘File[expireddaterange.txt] is Empty';

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.

about the author


  • Jan Drenner

    Some genuinely good information, Sword lily I noticed this.

  • Broderick Mooe

    I just like the helpful information you provide on your articles. I will bookmark your blog and test again right here regularly. I am somewhat sure I’ll learn plenty of new stuff right here! Best of luck for the next!

  • Jonathan Eschborn

    You actually make it appear really easy along with your presentation however I in finding this matter to be really something that I think I might never understand. It sort of feels too complicated and very wide for me. I am taking a look forward in your subsequent publish, I will attempt to get the hold of it!

  • Dominic Ravo

    Have you ever thought about publishing an e-book or guest authoring on other blogs? I have a blog based upon on the same information you discuss and would love to have you share some stories/information. I know my readers would appreciate your work. If you’re even remotely interested, feel free to send me an e mail.

  • software protection dongle

    Yeah bookmaking this wasn’t a bad determination good post! .


    Wonderful web site. Lots of helpful information here. I’m sending it to a few pals ans also sharing in delicious. And of course, thanks in your sweat!

  • lumene skin care

    Helpful information. Lucky me I discovered your web site by accident, and I’m stunned why this accident didn’t happened in advance! I bookmarked it.

  • black men skin care

    You really make it seem really easy with your presentation however I in finding this topic to be actually something that I believe I might by no means understand. It seems too complex and very large for me. I’m having a look ahead to your subsequent put up, I will attempt to get the cling of it!

  • muscle

    Great write-up, I am normal visitor of one¡¦s blog, maintain up the excellent operate, and It is going to be a regular visitor for a lengthy time.

  • automobile cup holders

    I’ve been browsing on-line greater than three hours as of late, but I by no means discovered any fascinating article like yours. It¡¦s beautiful worth sufficient for me. In my view, if all site owners and bloggers made good content as you probably did, the internet might be a lot more useful than ever before.

  • lamia

    Thanks used for another informative place. Everyplace else might I get that kindly of info printed in such a great way? I’ve a project that I’m just at this moment functioning on

  • cawk