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.

cron jobs - how to run a simple php script

Discussion in 'General Discussion' started by adentone, Feb 17, 2005.

  1. adentone

    adentone Registered

    Joined:
    Feb 17, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Spokane Valley, WA
    I am trying to get a cron job to run a simple php script using the "standard" cron job method (non-expert).

    I am not sure what to execute the script with...
    lynx -dump www.mysite.com/folder/simplescript.php
    is what I have tried, but it doesn't want to work

    I tried just put in the relative and absolute path to the file,
    but this doesn't seem to work, either

    I do not need any output, I just need to manipulate a db and send an email depending on settings in the db.

    Help!
    Thanks!
     
  2. jester.ro

    jester.ro Well-Known Member
    PartnerNOC

    Joined:
    Feb 6, 2004
    Messages:
    304
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Bucharest, Romania
    cPanel Access Level:
    DataCenter Provider
    try


    php -f /home/your_username/public_html/script.php
     
  3. adentone

    adentone Registered

    Joined:
    Feb 17, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Spokane Valley, WA
    nope - still not working

    good thinking though!
    I am pretty sure PHP is installed as an apache module....on linux
     
  4. dalem

    dalem Well-Known Member
    PartnerNOC

    Joined:
    Oct 24, 2003
    Messages:
    2,577
    Likes Received:
    40
    Trophy Points:
    48
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    try

    /usr/bin/wget -O - /home/your_username/public_html/script.php
     
  5. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Does running

    php -f /home/your_username/public_html/script.php

    give any errors? That would be the ideal way of running the script, as it would not spawn an apache instance.
     
  6. DigitalN

    DigitalN Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    420
    Likes Received:
    1
    Trophy Points:
    18
    Try the following, 'php' may not be in the users path for that cron job.

    0 1 * * * /usr/bin/php -q /home/your_username/public_html/script.php

    Running

    # /usr/bin/php -q /home/your_username/public_html/script.php

    From command line will do the same as the cron job would do, as has been mentioned.
     
  7. adentone

    adentone Registered

    Joined:
    Feb 17, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Spokane Valley, WA
    php -f -q /home/your_username/public_html/script.php
    seemed to work great!!
    thanks for your help!!


     
  8. spaceman

    spaceman Well-Known Member

    Joined:
    Mar 25, 2002
    Messages:
    481
    Likes Received:
    0
    Trophy Points:
    16
    fyi:

    man php

    "If none of -r or -f is present but a single parameter is given then this parameter is taken as the filename to parse and execute (same as with -f). If no parameter is present then the standard input is read and executed."

    i.e. you don't have to specify -f

    ... but I also have a question: I've seen php -q in use, but can't see what the -q option does. Any takers?

    Thanks
     
Loading...

Share This Page