Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 19
  1. #1
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default Cronjob doesnīt work

    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. #2
    Member
    Join Date
    Sep 2004
    Posts
    21

    Default

    Quote Originally Posted by dnagency
    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?
    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. #3
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    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. #4
    Member sawbuck's Avatar
    Join Date
    Jan 2004
    Posts
    1,310
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Might try adding the path to php and wget.

  5. #5
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    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. #6
    Member sawbuck's Avatar
    Join Date
    Jan 2004
    Posts
    1,310
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Try /usr/bin/php and /usr/bin/wget

  7. #7
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    tried... same results thx for trying to help me though

  8. #8
    Member sawbuck's Avatar
    Join Date
    Jan 2004
    Posts
    1,310
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #9
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    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. #10
    Member
    Join Date
    Sep 2004
    Posts
    21

    Default

    Quote Originally Posted by dnagency
    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...
    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. #11
    Member sawbuck's Avatar
    Join Date
    Jan 2004
    Posts
    1,310
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Might also confirm that crond is actually running:
    ps -ax | grep crond

  12. #12
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    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. #13
    Member
    Join Date
    Sep 2004
    Posts
    21

    Default

    Quote Originally Posted by dnagency
    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
    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. #14
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    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. #15
    Member
    Join Date
    Oct 2004
    Posts
    27

    Default

    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

Similar Threads & Tags
Similar threads

  1. Named doesn't work !
    By Scotchys in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 09-12-2006, 08:26 AM
  2. Exim doesn't work
    By jsilvestre in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 01-04-2006, 08:18 PM
  3. Cpanel doesn`t work
    By rambg in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 12-26-2004, 08:43 AM
  4. skipsquirrelmail doesn't work
    By krava in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-13-2004, 12:56 AM
  5. FrontPage98 doesn't work
    By imagic in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-14-2003, 11:07 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube