Author |
Message |
J Becket #1 / 11
|
 Wondering about using PHP for CRON jobs...
I'm going to be experimenting with using cron jobs for a project in the near future, and was wondering what experiences people have with using PHP for cron jobs? I guess I'm asking if there are any complete "gotcha's" that people have been caught out with, or is it all pretty standard stuff ?
http://www.*-*-*.com/ (Home Page) http://www.*-*-*.com/ (Development Work) http://www.*-*-*.com/ (Pet Project)
|
Tue, 26 Apr 2005 22:49:03 GMT |
|
 |
Pierre-Louis LAMBALLAI #2 / 11
|
 Wondering about using PHP for CRON jobs...
Quote:
> I'm going to be experimenting with using cron jobs for a project in > the near future, and was wondering what experiences people have with > using PHP for cron jobs?
Use Perl or C for that. But be careful: as a CRON-CGI don't start using a browser, the related path for files are different! To test correctly your CRON-CGI, launch it using a telnet tool. PL Lamballais -- *--------------------------------------------------------------------*
- Responsable Site Internet QAMA - (HTML, JavaScript, JAVA, PHP et Perl) Qama - Leader Fran?ais de Quincaillerie pour Meubles et Agencements http://www.qama.fr http://pro.wanadoo.fr/pl.lamballais/ ; Home Page *--------------------------------------------------------------------*
|
Tue, 26 Apr 2005 23:04:28 GMT |
|
 |
jack #3 / 11
|
 Wondering about using PHP for CRON jobs...
Quote:
> I'm going to be experimenting with using cron jobs for a project in > the near future, and was wondering what experiences people have with > using PHP for cron jobs?
I use php for lot of my cron jobs... I used to call php from shell as cgi, but lately I call php scripts from cron by wget, and this way it works fine with apache module php, and I don't have to have php installed as cgi. -- --- --- --- --- --- --- ---
|
Tue, 26 Apr 2005 23:09:39 GMT |
|
 |
J Becket #4 / 11
|
 Wondering about using PHP for CRON jobs...
Quote:
>> I'm going to be experimenting with using cron jobs for a project in >> the near future, and was wondering what experiences people have with >> using PHP for cron jobs? >I use php for lot of my cron jobs... >I used to call php from shell as cgi, but lately I call php scripts from >cron by wget, and this way it works fine with apache module php, and I don't >have to have php installed as cgi.
Thanks - that sounds really encouraging. The main thing we are thinking about (have yet to test), is use of MySQL in the cron job to make decisions - and while we know that Perl is just as happy talking to MySQL, it might be nice (in this case) to use PHP across the board - it's part of a system involving a thin client done in PHP...
http://www.kafooey.com (Home Page) http://www.pluggedout.com (Development Work) http://www.thoughtcafe.co.uk (Pet Project)
|
Tue, 26 Apr 2005 23:44:06 GMT |
|
 |
J Becket #5 / 11
|
 Wondering about using PHP for CRON jobs...
On Fri, 08 Nov 2002 16:04:28 +0100, Pierre-Louis LAMBALLAIS Quote:
>> using PHP for cron jobs? >Use Perl or C for that. But be careful: as a CRON-CGI don't start using >a browser, the related path for files are different! To test correctly >your CRON-CGI, launch it using a telnet tool.
I understand completely what you are saying, and normally we would be using Perl or C, but we have a thin client in this project that is using PHP and MySQL extensively - so it would make sense to use PHP for the cron jobs that are going to be talking to the MySQL databases. We would love to keep things simple if we can :)
http://www.kafooey.com (Home Page) http://www.pluggedout.com (Development Work) http://www.thoughtcafe.co.uk (Pet Project)
|
Tue, 26 Apr 2005 23:46:59 GMT |
|
 |
David Mackenzi #6 / 11
|
 Wondering about using PHP for CRON jobs...
Quote: > I'm going to be experimenting with using cron jobs for a project in > the near future, and was wondering what experiences people have with > using PHP for cron jobs? > I guess I'm asking if there are any complete "gotcha's" that people > have been caught out with, or is it all pretty standard stuff ?
I have a cron running for a kind of "on this day" system. The script connects to a MySQL db, runs a query and sends out an e-mail to each person on the list. I'm far from a UNIX bod, and I managed it without any problems. I did a fair bit of experimenting with running it from the command line, but, as before no real problems. -- David.
|
Tue, 26 Apr 2005 23:58:07 GMT |
|
 |
Billy Harve #7 / 11
|
 Wondering about using PHP for CRON jobs...
Quote: >I'm going to be experimenting with using cron jobs for a project in >the near future, and was wondering what experiences people have with >using PHP for cron jobs? >I guess I'm asking if there are any complete "gotcha's" that people >have been caught out with, or is it all pretty standard stuff ?
While it's not as efficient as C, I find it great for rapid and easy development and so I use PHP for several cron jobs. Some gotchas from my perspective: 1. Insure that you have some way of checking to see that only one instance of your application is running at a time if it's going to operate on a common directory or file and may take longer than expected. 2. If you call the apache-module using wget, insure that your job outputs some data to the "screen" as it's executing - just use -O/dev/null for the wget job. I haven't recently checked but wget would time out regardless of any flags passed to it if no data was forthcoming. 3. Depending on the requirements of the job, you may want to build some "sleeps" into your loops. Executing a large PHP job on a small system can drag it into swapping. For example I have a large job that graphically processes and sends out about 50 emails of images every morning from a small machine. It's otherwise unuseable during that time. Billy
|
Tue, 26 Apr 2005 23:51:13 GMT |
|
 |
KAH #8 / 11
|
 Wondering about using PHP for CRON jobs...
Quote: > The main thing we are thinking about (have yet to test), is use of > MySQL in the cron job to make decisions - and while we know that Perl > is just as happy talking to MySQL, it might be nice (in this case) to > use PHP across the board - it's part of a system involving a thin > client done in PHP...
PHP and MySQL are great friends ;-)) I (and I'm not alone) use MySQL in pretty much every larger script/site I write in PHP. Take a look at the MySQL chapter of the manual. KAH
|
Wed, 27 Apr 2005 01:40:54 GMT |
|
 |
Nikolai Chuvakh #9 / 11
|
 Wondering about using PHP for CRON jobs...
Quote: > I'm going to be experimenting with using cron jobs for a project in > the near future, and was wondering what experiences people have with > using PHP for cron jobs?
I have used PHP scripts with cron a lot. Since I am using a slightly outdated PHP version that doesn't support the command-line mode, I usually write a shell script to be put into cron.* which looks like this: cd /tmp wget http://localhost/path/myscript.php rm myscript.* -f Cheers, NC
|
Wed, 27 Apr 2005 03:51:27 GMT |
|
 |
Mikael L?fstran #10 / 11
|
 Wondering about using PHP for CRON jobs...
Quote:
> > I'm going to be experimenting with using cron jobs for a project in > > the near future, and was wondering what experiences people have with > > using PHP for cron jobs? > I have used PHP scripts with cron a lot. Since I am using a slightly > outdated PHP version that doesn't support the command-line mode, I > usually write a shell script to be put into cron.* which looks like > this: > cd /tmp > wget http://localhost/path/myscript.php > rm myscript.* -f > Cheers, > NC
In this case you might want to try wget <url> --quiet -O - > /dev/null Then you won't have to delete some file after running wget :) /Micke
|
Wed, 27 Apr 2005 05:18:21 GMT |
|
 |
Mark Youn #11 / 11
|
 Wondering about using PHP for CRON jobs...
Quote:
> > > I'm going to be experimenting with using cron jobs for a project in > > > the near future, and was wondering what experiences people have with > > > using PHP for cron jobs? > > I have used PHP scripts with cron a lot. Since I am using a slightly > > outdated PHP version that doesn't support the command-line mode, I > > usually write a shell script to be put into cron.* which looks like > > this: > > cd /tmp > > wget http://localhost/path/myscript.php > > rm myscript.* -f > > Cheers, > > NC > In this case you might want to try > wget <url> --quiet -O - > /dev/null > Then you won't have to delete some file after running wget :) > /Micke
Or a >slightly< better version of the above: wget <url> --quiet -O /dev/null (outputs right to /dev/null instead of to stdout-redirected-to-/dev/null)
|
Sun, 01 May 2005 01:03:55 GMT |
|
|