Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    151
    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:
    166
    Location:
    Bucharest, Romania
    cPanel Access Level:
    DataCenter Provider
    try


    php -f /home/your_username/public_html/script.php
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. adentone

    adentone Registered

    Joined:
    Feb 17, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    151
    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,693
    Likes Received:
    71
    Trophy Points:
    203
    Location:
    SLC
    cPanel Access Level:
    DataCenter Provider
    try

    /usr/bin/wget -O - /home/your_username/public_html/script.php
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,712
    Likes Received:
    96
    Trophy Points:
    328
    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:
    168
    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:
    151
    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:
    497
    Likes Received:
    2
    Trophy Points:
    318
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice