Cron job (php script) not sunning?

Discussion in 'Free Hosting' started by pietje63, Jul 30, 2012.

Thread Status:
Not open for further replies.
  1. pietje63

    pietje63 New Member

    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Cron job (php script) not running?

    I have the following cron jobs configured

    script 1, running each 30 minutes (15 and 45 past hour)

    [TABLE="class: dynamic_table"]
    [TR="class: dt_header_row"]
    [TH]Minute
    [/TH]
    [TH]Hour
    [/TH]
    [TH]Day
    [/TH]
    [TH]Month
    [/TH]
    [TH]Weekday
    [/TH]
    [TH]Command
    [/TH]
    [/TR]
    [TR="class: dt_info_row info-odd"]
    [TD]15,45
    [/TD]
    [TD]*
    [/TD]
    [TD]*
    [/TD]
    [TD]*
    [/TD]
    [TD]*
    [/TD]
    [TD]/usr/local/bin/php $HOME/public_html/cronjob.php
    [/TD]
    [/TR]
    [/TABLE]

    script 2, running once in 2 days



    [TABLE="class: dynamic_table"]
    [TR="class: dt_header_row"]
    [TH]Minute
    [/TH]
    [TH]Hour
    [/TH]
    [TH]Day
    [/TH]
    [TH]Month
    [/TH]
    [TH]Weekday
    [/TH]
    [TH]Command
    [/TH]
    [/TR]
    [TR="class: dt_info_row info-even"]
    [TD][/TD]
    [TD][/TD]
    [TD]2
    [/TD]
    [TD]*
    [/TD]
    [TD]*
    [/TD]
    [TD]/usr/local/bin/php $HOME/public_html/cronjob2.php
    [/TD]
    [/TR]
    [/TABLE]
    Both scripts run fine from the browser and log to a file. But the cronjobs appear to not be running. Any ideas?
     
    Last edited: Jul 31, 2012
  2. misson

    misson Community Paragon Community Support

    Messages:
    2,572
    Likes Received:
    72
    Trophy Points:
    48
    How are you checking whether or not the cron jobs are running? Are you logging the output of the PHP scripts?
     
  3. pietje63

    pietje63 New Member

    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Yes, I'm logging (via php fwrite) to a file. When I run the file from the browser I see it is working/logging.
     
  4. mraz

    mraz New Member

    Messages:
    95
    Likes Received:
    3
    Trophy Points:
    0
    just curious, because time is set as every 15 and 45 of the hour, have you tried to change it to run every min to test it out?

    because needing to wait every 30mins for it run is abit tiring...
     
  5. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Every minute is a violation of the TOS and the cron will be discarded.
     
  6. mraz

    mraz New Member

    Messages:
    95
    Likes Received:
    3
    Trophy Points:
    0
    oops sorry - every 5 mins then
     
  7. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    No. If there is an error running your script via cron your logging will not do anything.

    Use a command line like

    Code:
    /usr/bin/php   /home/igor/public_html/cron_job.php >>/home/igor/public_html/cron_log.txt 2>&1
    where "igor" is your cPanel username.

    This will log any "echo" command output along with any failures (file not found, etc).

    Not sure if your second script is set to run when you want.
     
    Last edited: Jul 31, 2012
  8. pietje63

    pietje63 New Member

    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    I choosed for 15,45 to eb able to run both cron jobs together.

    I thought testing by 'browsing' was fine, and than run the script each thirty minutes. I'm not that much in a hurry that I need to run it more often. Would you expect anything else by editing the run frequency?

    Thank you. That is a fair point. Will try tonight.

    Logging added; will report test of log later. Timing was indeed incorrect, now also updated

    It looks like the script is running :) probably the path to fwrite is different when running cron-php compared to 'normal'.

    Thanks for all input!
     
    Last edited: Jul 31, 2012
Thread Status:
Not open for further replies.

Share This Page