Re: run php script in background
| From: | Carlos Mabalot | Date: | Tue, 10 Oct 2000 03:40:52 +0000 |
| Subject: | Re: run php script in background | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38963@lists.php.net to get a copy of this message | ||
Niraj,
I do a lot of tracking using php programs in cron. It is really easy to
run as a user crontab. Just treat it as a CGI executable that you
implicitly define the program using a Sha-Bang. Remember this is Perl?
File : some.php
--- Begin PHP Script:
#! /usr/bin/local/php -q
<?php
// Notes : You must define the fully qualified directory of the php
// executable of the php that you want to use (CGI Version)
//
//
// PHP Script Here =o)
?>
--- End PHP Script
With that in place, you can run the script anywhere using the complete
path or the logical path:
/home/sites/web/users/niraj/some.php
-or from the same directory:
./some.php
In CRONTAB, however you have to use the complete path (symbolic paths
work in Linux):
File : crontab
--- Begin Imported CRONTAB
* * * * * /home/sites/web/users/niraj/some.php >/dev/null 2>&1
--- End Imported CRONTAB
Use crontab command to add to your user cron:
crontab crontab
crontab -l *to make sure it is there.
Note that all output in your cron goes to /dev/null. This is important
unless you want emails every single time that the cron runs and you have
output or supperfluous HTML spaces in your PHP. Remove the 2>&1 if you
want to be emailed errors as it should default to [cronowner]@localhost.
Cheers!!!
--
)
° · / |
· °,/ |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=.=·~²¸,-~^º´.`,~³=-=-=-=-=-=-=-=-=-
Carlos Mabalot \_____)\_____ ______ __
infomatic@digitalhum.net /--v____ »_< / __/ / ___ _____/ /__
877.504.5117 )/ _\ \/ _ \/ _ `/ __/ '_/
858.831.0839 FAX · /___/_//_/\_,_/_/ /_/\_\
http://www.digitalhum.net Internet Server
Series 2000
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Senior Programming Engineer High Availability Linux Web Servers
800.470.7946 x130 Custom Application Development
http://www.totalinet.net Digital Hum Interactive
Networks
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
niraj.dave@globalwebwise.com wrote:
>
> dear
>
> want to place php script in crontab to make it run
> it as a background process
>
> am using php 4.12/php 4.0.2/php.3.0.16
> redhat 6.2 with apache_1.3.12+mysql3.xx+
>
> thanx in advance
>
> niraj
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net