The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cronjob doesn´t work

Discussion in 'General Discussion' started by dnagency, May 3, 2006.

  1. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I kept trying to run a cronjob now for hours and hadn´t been able to. Hopefully someone of you can help me on that :)

    Here is the cronjob lines I used:

    10 * * * * wget -O /dev/null http://www.mydomain.com/script.php
    10 * * * * php /home/myaccount/public_html/script.php

    both lines work fine when being started from putty, but they don´t work when trying to use them as a cronjob. script.php ist just a simple php script fetching data from a mysql and sending it to a mailbox.

    Does anyone of you know where the problem could be?
     
  2. DalQuest

    DalQuest Member

    Joined:
    Sep 22, 2004
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Have you checked the cron log to see if the two entries are actually being run and if so, any errors? Also, what file did you add those entries to and what OS you running cpanel on?

    -D-
     
  3. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    thx for the reply :)

    to answer the questions:

    I didn´t add those entries to a file but used the cpanel feature to setup the crons (I only put it here the "unix"-format so it´s easier to see who they are setup :)

    I checked those files:

    var/spool/cron/account
    the crons are visible there in that format:
    MAILTO="account"
    * 15 * * * wget -O /dev/null http://www.domain.com/script.php
    * 15 * * * php /home/account/public_html/script.php



    var/log/cron
    no error logged there, only the actions I did when trying to setup the crons (using cpanel to do so) like e.g.:

    ....
    May 3 14:35:02 myserver crontab[23482]: (account) REPLACE (account)
    May 3 14:37:53 myserver crontab[23686]: (account) LIST (account)
    May 3 14:37:53 myserver crontab[23688]: (account) LIST (account)
    May 3 14:49:57 myserver crontab[24383]: (account) BEGIN EDIT (account)
    ....

    So it basically seems as if the crons would simply not being started somehow at the time given... as mentioned the script for sure works (works fine on putty - both methods)...

    Are there any other files I should check?
     
  4. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Might try adding the path to php and wget.
     
  5. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    what path is php and wget usually in at standard cpanel setup? (I am not really much into server admin I have to admit ;)). But if that was the problem wouldn´t that as well lead to the scripts not working in putty as well when writing them there without the path? But in putty it works...

    I forgot to mention in my post before that I am using Redhad Linux 9 (since I was asked for it) :)

    best regards, dna
     
  6. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Try /usr/bin/php and /usr/bin/wget
     
  7. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    tried... same results :( thx for trying to help me though :)
     
  8. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Looking over your posts can see you have changed from 10 * * * * to * 15 * * *.

    If you want every 15 minutes using the second example then do: * /15 * * * *.

    Also can try /usr/local/bin/php -q /home/myaccount/public_html/script.php
     
  9. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    well I changed since I wanted the job to run every minute on hour 15 just to check wether it would do anything at all (while it hadn´t in fact)... :)

    tried the other example as well... still no result...
     
  10. DalQuest

    DalQuest Member

    Joined:
    Sep 22, 2004
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Just for fun, put them in the main root cron file and see if it runs. On my test CentOS box with cpanel the file is /var/spool/cron/root

    Check the logfile to see if they run from there.

    -D-
     
  11. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Might also confirm that crond is actually running:
    ps -ax | grep crond
     
  12. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    For crond I receive that (using putty at root access):
    19393 pts/0 D 0:00 grep crond


    I put the crons in root´s crontable, but still no effect...

    best regards, dna :)
     
  13. DalQuest

    DalQuest Member

    Joined:
    Sep 22, 2004
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Ok, going back and looking at your original post, I noticed something.

    MAILTO="account" <----------------------------- what is this and is it in your cron file?
    * 15 * * * wget -O /dev/null http://www.domain.com/script.php

    -D-
     
  14. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    it´s in the cronfile of that account, appearantly created by Cpanel - as far as I know it´s for that: In case the script gives an output, it would send to the mail specified there the output...

    but that´s e.g. not in my root´s cron and there it doesn´t work as well... so I guess that should not be the prob :)
     
  15. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    finally works!!! :)))))

    obviously it had been the crond... gave it a try, writing that in putty: "crond"

    after that when doing that check you mentioned, sawbuck, it would give back that then:
    21067 ? S 0:00 crond
    21077 pts/0 D 0:00 grep crond

    And now all of a sudden the crons work (no mather wether with wget or php).

    Thx a lot to all of you guys helping me out on that one :)


    best regards, dna
     
  16. DalQuest

    DalQuest Member

    Joined:
    Sep 22, 2004
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1

    Good to hear. I apparently didn't read the entire response you got back the first time and missed the grep part of it.


    Now you need to find out if crond is starting when you boot your system, and if so, why it wasn't running when you were first trying this.

    -D-
     
  17. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    it seems you are overestimating my skills in serveradministration a lot... ;)

    dna :)
     
  18. DalQuest

    DalQuest Member

    Joined:
    Sep 22, 2004
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Ok, first step, see if crond is starting when the system starts by simply rebooting your system and checking the ps command output for the crond process.

    It should list two entries as your last post showed, the actual crond process and the command you issued (i.e. ps | grep crond or something similar).

    If it does show the two after rebooting, just check it often to make sure it is still running, say every couple hours the first day, then maybe twice the next day, them maybe once a day for a week. If all is good, it might have been nothing to worry about.

    If you are still finding it not running there are other issues you need to address and people here are usually willing to help you find the answer.

    -D-
     
  19. dnagency

    dnagency Active Member

    Joined:
    Oct 21, 2004
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Thx for the guidelines :)

    seems to work fine now :)

    best regards, dna :)
     
Loading...

Share This Page