Re: [PHP] Best way to start a CRON
On Thu, April 20, 2006 4:03 am, Barry wrote: > What would be the best way to start a PHP Script via CRONJOB? > Should i use the 'php' command or use curl or lynx or something to > open that URL? Ideally just use CLI PHP. Slightly sub-optimal is CGI PHP with -q argument. Also use FULL PATH to the php binary, and to your script, because the cronjob may not (or may) be using the same "home" directory as you are. With a full path, you can't go wrong. Using curl or lynx will just waste an HTTP connection for no real reason. If, however, you need to run a cronjob on machine A, but have no shell access on A, and have shell access on B... Running a cron job on B to lynx to a page on A is a solution... Not a pretty solution. Probably not the best solution. Maybe not even a GOOD solution. Just A solution. PS You can also use -d and -c and other fun arguments to the CLI/CGI php binary to provide a specialized php.ini file or some over-rides to php.ini parameters. Very handy. Again, use FULL PATH to be safe. > The Script does a MySQL query, collects data and sends it via E-Mail > every monday morning to the recipient. cron doesn't much care what your script does. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to start a CRON
Pure Web Solution wrote: I run several PHP scripts via CRON in the following way: put the following in the top of the php script: #!/usr/local/bin/php -q (linux system - location of php bin) ^^^ If you're going to use this and in the CRONTAB I have the following: 10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php There's no need to repeat it here ^^^ (make the script executable) the -q supress HTML headers. _HTTP_ headers. This is only necessary if you're running an older version. The CLI (since 4.2 I think) automatically does this. http://www.php.net/manual/en/features.commandline.php -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to start a CRON
Actually, you can even use less "code" to do exactly the same thing (since you can EITHER make an excutable file with the shebang, which you start doing, but never actually do, OR call php to just read the file and execute the code inside it, which you in the end do). Basically, either: #!/usr/local/bin/php -q (linux system - location of php bin) at the top of the file, and make sure the crontab has execute permissions on that script, OR 10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php and make sure your crontab has read permission on the php file (no need for the shebang). As for the -q, I'm sure you meant HTTP headers and not HTML headers ;) (at least, I hope you did) - tul Pure Web Solution wrote: I run several PHP scripts via CRON in the following way: put the following in the top of the php script: #!/usr/local/bin/php -q (linux system - location of php bin) and in the CRONTAB I have the following: 10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php the -q supress HTML headers. hope this helps! Pure Web Solution http://www.purewebsolution.co.uk PHP, MYSQL, Web Design & Web Services Barry <[EMAIL PROTECTED]> wrote: Hello Everyone! What would be the best way to start a PHP Script via CRONJOB? Should i use the 'php' command or use curl or lynx or something to open that URL? The Script does a MySQL query, collects data and sends it via E-Mail every monday morning to the recipient. Any help will be appriciated :) Barry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to start a CRON
Pure Web Solution wrote: I run several PHP scripts via CRON in the following way: put the following in the top of the php script: #!/usr/local/bin/php -q (linux system - location of php bin) and in the CRONTAB I have the following: 10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php the -q supress HTML headers. hope this helps! Yes it does. Thanks :) -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to start a CRON
I run several PHP scripts via CRON in the following way: put the following in the top of the php script: #!/usr/local/bin/php -q (linux system - location of php bin) and in the CRONTAB I have the following: 10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php the -q supress HTML headers. hope this helps! Pure Web Solution http://www.purewebsolution.co.uk PHP, MYSQL, Web Design & Web Services Barry <[EMAIL PROTECTED]> wrote: > Hello Everyone! > > What would be the best way to start a PHP Script via CRONJOB? > Should i use the 'php' command or use curl or lynx or something to > open that URL? > > The Script does a MySQL query, collects data and sends it via E-Mail > every monday morning to the recipient. > > Any help will be appriciated :) > > Barry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to start a CRON
Barry a écrit : Hello Everyone! What would be the best way to start a PHP Script via CRONJOB? Should i use the 'php' command or use curl or lynx or something to open that URL? Hi, unless you need to be sure the http server is up and running, it's a better way to run your script via a cronjob. N F The Script does a MySQL query, collects data and sends it via E-Mail every monday morning to the recipient. Any help will be appriciated :) Barry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php