Results 1 to 8 of 8

Thread: cron jobs - how to run a simple php script

  1. #1
    Registered User
    Join Date
    Feb 2005
    Location
    Spokane Valley, WA
    Posts
    3

    Thumbs down cron jobs - how to run a simple php script

    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. #2
    cPanel Partner NOC cPanel Partner NOC Badge jester.ro's Avatar
    Join Date
    Feb 2004
    Location
    Bucharest, Romania
    Posts
    304

    Default

    try


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

  3. #3
    Registered User
    Join Date
    Feb 2005
    Location
    Spokane Valley, WA
    Posts
    3

    Default

    nope - still not working

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

  4. #4
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Oct 2003
    Posts
    2,003

    Default

    try

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

  5. #5
    Member
    Join Date
    Aug 2002
    Posts
    1,133

    Default

    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. #6
    Member
    Join Date
    Sep 2004
    Posts
    422

    Default

    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. #7
    Registered User
    Join Date
    Feb 2005
    Location
    Spokane Valley, WA
    Posts
    3

    Default

    php -f -q /home/your_username/public_html/script.php
    seemed to work great!!
    thanks for your help!!


    Quote Originally Posted by DigitalN
    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
    From command line will do the same as the cron job would do, as has been mentioned.

  8. #8
    Member
    Join Date
    Mar 2002
    Posts
    454

    Default

    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
    • Web Design Perth .:. Itomic Business Website Solutions of Perth, Western Australia

Similar Threads

  1. Cron Job, Run PHP script
    By bowers01 in forum New User Questions
    Replies: 2
    Last Post: 11-18-2010, 03:23 PM
  2. Script to check cron jobs
    By thewebhosting in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 09-18-2009, 11:14 PM
  3. Run CRON jobs now
    By SniffTheGlove in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 01-19-2009, 10:56 PM
  4. Replies: 3
    Last Post: 03-29-2007, 04:31 AM