Running automated scripts with CronJob

Discussion in 'PHP' started by nebhotep, May 10, 2008.

  1. #1
    Hi

    I am trying to set up a cronJob for my website. The CronJobs should execute the file located in public_html/mysite.com/CronJobs/MyScript.php
    I used Standard Cron Manager from my CPanel and I have provided this path.

    but it does not work...

    what is the root for CronJobs?
     
    nebhotep, May 10, 2008 IP
  2. eTechDude.com

    eTechDude.com Member

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #2
    if you have ssh access; login, type crontab -e
    this example to type in the file to run at 3am everyday:

    0 3 * * * /public_html/mysite.com/CronJobs/MyScript.php

    then crontab -l
    to list them
     
    eTechDude.com, May 10, 2008 IP
  3. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try
    or even make sure dir is right just open up your phpinfo and look under Apache Environment > DOCUMENT_ROOT
     
    cornetofreak, May 10, 2008 IP
  4. Rob Whisonant

    Rob Whisonant Well-Known Member

    Messages:
    156
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Try something like this.

    3 * * * * /usr/local/bin/php /home/path/to/script.php


    If that does not work you will need to use wget to execute the script via cron.

    Find out the path to your wget and change as needed.

    Then try this.

    29 0 * * * /sbin/wget http: / /www.sitename.com/path/to/script.php > /dev/null

    Re's
    Rob Whisonant
     
    Rob Whisonant, May 10, 2008 IP
  5. Rob Whisonant

    Rob Whisonant Well-Known Member

    Messages:
    156
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Take out the spaces of course in the http: / / Had to add the spaces to make it not format as a link.

    Re's
    Rob Whisonant
     
    Rob Whisonant, May 10, 2008 IP