how to use cron jobs

Discussion in 'PHP' started by kharearch, Dec 19, 2007.

  1. #1
    I want to use cron jobs to run my php file every week. URL of my file is -

    Sanganak.co.in/sunil/showdata2.php

    What should I write for -

    Command to run _____

    Please solve my query. thanks
     
    kharearch, Dec 19, 2007 IP
  2. Gawk

    Gawk Peon

    Messages:
    427
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Gawk, Dec 19, 2007 IP
  3. Boulder

    Boulder Well-Known Member

    Messages:
    806
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    118
    #3
    You would use a cron something like this to run a php file one time a week:


    5 4 * * sun php /home/servername/public_html/sunil/showdata2.php

    Don't forget the space between php and this /

    Be sure your "showdata2.php" file has the necessary permissions to be executable i.e.,("chmod 755").


    5 4 * * sun This setting will run at 5 minutes after 4 every sunday.

    So you will need to edit to the day you want and the time.


    If the above does not work try it like this:

    5 4 * * sun /usr/local/bin/php -q /home/servername/public_html/sunil/showdata2.php > /dev/null 2>&1


    Make sure to change servername to your server path name.


    Boulder
     
    Boulder, Dec 19, 2007 IP
    Meth_ likes this.
  4. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #4
    write in your commend
    php -q /Sanganak.co.in/sunil/showdata2.php

    set time as you want
     
    sunnyverma1984, Dec 19, 2007 IP
  5. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
  6. rtrocc

    rtrocc Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    rtrocc, Dec 19, 2007 IP
  7. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #7
    using cpanel cron option for standard user

    Put this in command box -> php -q /real path / to cron /file/cron.php

    choose the timing from list boxes as per your requirement

    Regards

    Alex
     
    kmap, Dec 19, 2007 IP
  8. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If you have a dedicated box there won't be cpanel, unless you install it.

    Its not necessary, that sort of stuff just clogs up your server.
     
    tonybogs, Dec 20, 2007 IP
  9. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #9
    If you have compiled Php as cgi you can do

    php-cgi /source/to/script.php
    php-cli /source/to/script.php

    yeah and cpanel sucks if you can do everything with shell.
     
    Kaizoku, Dec 20, 2007 IP