View Full Version : Simple Cron
stanvman
03-02-2006, 10:54 AM
I want to create a cron script, that runs my file update_playlist.php every 15 minutes. How would I do this???
rromanczuk
03-02-2006, 11:45 AM
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!
stanvman
03-02-2006, 02:25 PM
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
stanvman
03-02-2006, 02:33 PM
Wow, I'm a tard.
There is a specific section in the help center for my exact problem:
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&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.
mwmoriarty
05-24-2006, 06:44 PM
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
beyondxm
05-24-2006, 07:14 PM
stanvman: Do you have a shebang line in your php script thats pointing to php ?
Something like:
#!/usr/bin/php -q
Thanks,
Michael
beyondxm
05-24-2006, 07:16 PM
mwmoriarty: The -q stops headers from getting sent.
Make Sense ?
Thanks,
Michael
KnowProSE
05-24-2006, 07:19 PM
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:
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)
mwmoriarty
05-25-2006, 03:52 PM
Thanks for the answers about the -q option for cron jobs.
Michael
pixel.partnerz.net
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.