Cron job comamand to run a page

Discussion in 'PHP' started by KingCobra, Dec 10, 2009.

  1. #1
    I want to run a page (www.mysite.com/dir/myfile.php) every day in a certain taime (except 2 holly days; Friday & Saturday)

    Run time:
    --------------------
    Sunday to Thursday
    11:03 AM to 3:03 PM
    Every 3 minutes

    example: The page will run the following times-
    Sunday 11:03 AM
    Sunday 11:06 AM
    -----------------
    Sunday 03:03 PM
    Monday 11:03 AM
    Monday 11:06 AM
    -----------------
    Monday 03:03 PM

    What will be the command?

    PLEASE HELP
     
    KingCobra, Dec 10, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    something like this (not tried it):

    */3 11,12,13,14 * * 1,2,3,4,7 /path/myfile.php

    OR EVEN

    */3 11-14 * * 1,2,3,4,7 /path/myfile.php

    you'd prolly need to add 15 but it means it wont end at 15:03 - then you need to check if its past 15:03 in the php file and do nothing.

    http://www.linuxhelp.net/guides/cron/
     
    dimitar christoff, Dec 10, 2009 IP
  3. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #3
    but if it is a PHP file, you need to make sure it is being called with PHP (or cURL if applicable). I'm guessing my host may be a little different, but I have to put php, curl, or php5 in front of the path.

    Also, make sure the path is from your servers root (not necessarily the web directory)
     
    tguillea, Dec 10, 2009 IP
  4. fierceservers

    fierceservers Peon

    Messages:
    338
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Exactly, as in /home/accountusername/public_html/blabla.php

    Usually the php in front issue is true, but lately doesn't tend to happen so much anymore, usually it'll realize it needs the PHP interpreter (depending how the servers are configured). If you are having an issue though this is a good culprit to look at first!
     
    fierceservers, Dec 10, 2009 IP
  5. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #5
    you need /usr/local/bin/php or wget to execute php
     
    javaongsan, Dec 10, 2009 IP
  6. thuankkk

    thuankkk Active Member

    Messages:
    503
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    95
    #6
    thuankkk, Dec 16, 2009 IP
  7. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #7
    Check this post: http://forums.digitalpoint.com/showpost.php?p=13131447&postcount=10 (and the rest of the thread, too)
     
    Wogan, Dec 16, 2009 IP
  8. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #8
    KingCobra, Dec 21, 2009 IP
  9. ChrisMac

    ChrisMac Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi,

    Your command should look like:

    
    */3 11-15 * * 0-4 root wget -O /dev/null http://www.mysite.com/dir/myfile.php > /dev/null
    
    Code (markup):
     
    ChrisMac, Dec 21, 2009 IP
    thuankkk likes this.
  10. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #10
    ChrisMac ,

    Thank you.

    my country time: 22/12/2009 01:05:07 pm
    my server time : 22/12/2009 01:05:27 am

    so what will ve the command to match my country time.
     
    Last edited: Dec 21, 2009
    KingCobra, Dec 21, 2009 IP
  11. KingCobra

    KingCobra Well-Known Member

    Messages:
    289
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #11
    I received the following message in my mail

    /bin/sh: /mydir/myfile.php: No such file or directory

    what will be in command tab for this url www.mysite.com/mydir/myfile.php
     
    Last edited: Dec 22, 2009
    KingCobra, Dec 22, 2009 IP