Results 1 to 9 of 9

Thread: Simple Cron

  1. #1
    Join Date
    Feb 2006
    Location
    Norman, OK
    Posts
    15

    Default Simple Cron

    I want to create a cron script, that runs my file update_playlist.php every 15 minutes. How would I do this???

  2. #2
    Join Date
    Mar 2006
    Posts
    4

    Default Setting up a cron job to run a PHP file

    Hi stanvman,

    It's not too hard actually. You just need to go into the CPanel for your account, and click on the "Cron Jobs" icon. You'll see two options for how to set it up, Standard and Advanced. I've found Standard really is simpler. Takes a little of the thinging about how to configure the schedule out of it.

    Once you're in the Standard Cron Manager page, you'll see the form. In the command to run part, you'll want to plug in the command line you'll run. Here's where it gets alittle tricky actually. For files written in a programming language you usually need to call the interpretor for that language, passing the file as a variable. So here you'd want to put: /bin/php path/to/file/name

    So your command line would probably look something like this if the file were in the root of your home location:

    /bin/php /home/stantoni/update_playlist.php

    Now, you'll also see a line near the top of the page for an email address for the results to be emailed to. If you want to receive this, go ahead and plug on in and once you set the frequency you are done. If you DON'T want to get the results, add >/dev/null 2>&1 to the end of the line so it looks like:

    /bin/php /home/stantoni/update_playlist.php >/dev/null 2>&1

    Hope that helps, without being TOO much info!

  3. #3
    Join Date
    Feb 2006
    Location
    Norman, OK
    Posts
    15

    Default

    Thanks for the help so far.

    I can see the finish line, ...but right now I'm getting this error sent to me, each time it tries to execute.

    /bin/sh: /bin/php: No such file or directory

    I'm using this command for my cron.
    /bin/php /home/stantoni/public_html/playlist_updater.php

  4. #4
    Join Date
    Feb 2006
    Location
    Norman, OK
    Posts
    15

    Default

    Wow, I'm a tard.
    There is a specific section in the help center for my exact problem:
    http://helpdesk.bluehost.com/kb/inde...root=25&id=190

    /usr/bin/php -q /home/USERNAME/public_html/PathToFile

    I just had to put /usr/ in before bin.

    Thanks again for your help, rromanczuk. Mucho props!

    And, out of curiosity, what level of permission do I have to have on this php file for it to work? I put a 777 on it while testing, just to make sure that this wouldn't be a problem.
    Last edited by stanvman; 03-02-2006 at 01:53 PM.

  5. #5
    Join Date
    Feb 2006
    Posts
    6

    Default Cron jobs continued

    Hi,

    Anyone know what the -q is for in the cron job command?

    I tried looking it up on the net but could'nt find any specifics.

    Thanks,

    Michael

  6. #6
    Join Date
    May 2006
    Posts
    20

    Default

    stanvman: Do you have a shebang line in your php script thats pointing to php ?

    Something like:
    #!/usr/bin/php -q

    Thanks,
    Michael

  7. #7
    Join Date
    May 2006
    Posts
    20

    Default

    mwmoriarty: The -q stops headers from getting sent.

    Make Sense ?

    Thanks,
    Michael

  8. #8
    Join Date
    May 2006
    Location
    Planetary Tourist
    Posts
    54

    Smile

    Quote Originally Posted by mwmoriarty
    Hi,

    Anyone know what the -q is for in the cron job command?

    I tried looking it up on the net but could'nt find any specifics.

    Thanks,

    Michael
    That's not an option for cron, it's an option for wget. Options for cron would be behind it... all of this is based on your seeing this:
    Code:
    wget -q -O http://www.server.com/mycron.php
    The '-q' is for quiet mode, so that wget doesn't act like Poindexter.
    The '-O' is for indicating the filename follows (http://www.server.com/mycron.php)
    --
    Taran Rampersad
    Presently in: San Fernando, Trinidad and Tobago
    Looking for contracts/work!
    http://www.OpenDepth.com
    http://www.knowprose.com
    http://www.digitaldivide.net/profile/Taran
    Pictures

    "Criticize by creating." — Michelangelo

  9. #9
    Join Date
    Feb 2006
    Posts
    6

    Default Re. Cron codes

    Thanks for the answers about the -q option for cron jobs.

    Michael
    pixel.partnerz.net

Posting Permissions

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