Results 1 to 7 of 7
  1. #1

    How to set up a crontab...

    Alright, so I have a script I want to run on crontab. It's a commercial script I purchased and the documentation says to put this on cron if I want it to run automatically each day:

    /usr/local/bin/php /home/dangro/public_html/[program]/[program].php

    I have no problem editing crontabs, I added that, fine. But I realized after two days it wasn't running, and when I execute that commend manually I see that it fails with an error about opening a file.

    I realized that if I cd into the [program.php]'s directory and run the command there it's fine. If it's run from any other directory it can't find the files it's looking for.

    So what is the proper method of remedying this? How do I specify what directory to run the command from on cron? Do I need to make a script which cd's there before running it (will that work?)?

    Thanks,
    Dan
    Dan Grossman - dan @ awio.com
    My Blog | Affiliate Program for Web Hosts

  2. #2
    Join Date
    Sep 2002
    Location
    Chicago, Illinois
    Posts
    882
    are you running the cron as a proper user ?

  3. #3
    Quote Originally Posted by Neosurge
    are you running the cron as a proper user ?
    It's in the root user's crontab.
    Dan Grossman - dan @ awio.com
    My Blog | Affiliate Program for Web Hosts

  4. #4
    Join Date
    Sep 2002
    Location
    Chicago, Illinois
    Posts
    882
    Check the script to see that it is calling out the includes properly.

  5. #5
    Quote Originally Posted by Neosurge
    Check the script to see that it is calling out the includes properly.
    The script is encoded, I can't modify it. I just need to know how to run it from the proper directory.
    Dan Grossman - dan @ awio.com
    My Blog | Affiliate Program for Web Hosts

  6. #6
    Join Date
    Nov 2005
    Posts
    352
    Quote Originally Posted by Dan Grossman
    The script is encoded, I can't modify it. I just need to know how to run it from the proper directory.
    * * * * * cd /home/dangro/public_html/[program]; /usr/local/bin/php /home/dangro/public_html/[program]/[program].php

    Fix the paths as well as the running times (using "* * * * *" makes it run every minute) and it should work.

  7. #7
    Oh yes, I have the run times in there, I just didn't paste them here. Thanks for the help
    Dan Grossman - dan @ awio.com
    My Blog | Affiliate Program for Web Hosts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •