Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Our cron script stopped working in different dates in August. What can be the possible reasons? We did not change anything. Our hosting showed us a log where we can see that cron is executing our scripts. But, nothing is happening in our scripts.

If we manually execute the scripts, we're getting correct results like before.

I showed the commands to hosting and they showed me that the commands are working. What should I tell my hosting? what should I do?

They are php scripts which are executed by CRON and they just post to facebook and twitter. They don't execute any hard or huge things. I even asked my hosting if we broke any rules.

share|improve this question

migrated from stackoverflow.com Sep 7 '12 at 18:06

This question came from our site for professional and enthusiast programmers.

    
This may not be a great question for this forum. Without knowing what your scripts are, and as the various things that could go wrong with them (i.e. loss of database connectivity, running out of disk space, etc.) there really isn't much anyone can do to help. –  Mike Brant Sep 7 '12 at 18:04
    
Try turning on display errors for the cron-scripts, and make sure the emails from cron go where you can read the output, if any. –  rrehbein Sep 7 '12 at 18:06
    
What does your script look like? –  quanta Sep 7 '12 at 18:08
    
Also please check the /var/log/cron file. –  sandeep.s85 Sep 7 '12 at 18:09

1 Answer 1

up vote 1 down vote accepted

My PHP code had

require $_SERVER'DOCUMENT_ROOT']."/myfile.php";

it was not working from shell cron.

I changed it following code.

require "mydir/myfile.php"

It started working. Basically, $_SERVER'DOCUMENT_ROOT'] was not working with require for shell execution. Please notice that the script was working with the both two codes for direct URL access from browsers. But first code is not working only for CRON.

share|improve this answer
    
As the PHP script is not being executed by a web server you can't use web server super globals such as $SERVER. You've also left out the opening square bracket, so that code would fail with a syntax error anyway. –  John Gardeniers Sep 11 '12 at 3:31
    
I did not know that. Thanks! –  Robi Sep 21 '12 at 19:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.