Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-16 Thread Martin Marques
El Lun 15 Sep 2003 17:47, Jonathan Villa escribió:
 I believe this would need php to installed as a cgi, which I prefer not
 to do...

If you don't want to because of security resons, please install it and don't 
leave it in the hands of the web server.
If you don't want to go through the problem of compiling, then you might think 
about finding on the net a binary PHP for you operating system.


--
 08:55:02 up 25 days, 45 min,  4 users,  load average: 0.71, 0.51, 0.50
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telematica
   Universidad Nacional
del Litoral
-

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
From: Jonathan Villa [EMAIL PROTECTED]


 I have an application which creates temporary tables.  My plan is to
 remove them after a 24 hour period and only those which are have a
 created time greater than 24 hours.  That part I can do, my question is
 how will I be able to run this script which is a 2 part script.

 First thing I do is pull the names of the temporary tables which are
 going to be deleted from another table.  From this result set, I need to
 DROP tables as well as remove the reference to them from the first
 table.

 I understand that I can run PHP from the command line but this would
 require PHP to installed as a CGI which I prefer not to do.

 I was hoping I that I could use CRON to run this script once a day...

You can. Create a php script that does what you want. It should not create
any output, either log status/error messages or send an email.

If you save it as cron.php, you can use a command such as the following in
your crontab:

wget -q -O - www.domain.com/cron.php  /dev/null

I'm assuming you know the specifics of cron or can google for it. :)

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread Jonathan Villa

Interesting... how does this fair concerning security?  So I'll have to
have this file located in my document root, is this a good thing?  My
current directory structure consists of several files located outside
the doc root.  I guess I could always include it onto a page


On Mon, 2003-09-15 at 14:49, CPT John W. Holmes wrote:
 From: Jonathan Villa [EMAIL PROTECTED]
 
 
  I have an application which creates temporary tables.  My plan is to
  remove them after a 24 hour period and only those which are have a
  created time greater than 24 hours.  That part I can do, my question is
  how will I be able to run this script which is a 2 part script.
 
  First thing I do is pull the names of the temporary tables which are
  going to be deleted from another table.  From this result set, I need to
  DROP tables as well as remove the reference to them from the first
  table.
 
  I understand that I can run PHP from the command line but this would
  require PHP to installed as a CGI which I prefer not to do.
 
  I was hoping I that I could use CRON to run this script once a day...
 
 You can. Create a php script that does what you want. It should not create
 any output, either log status/error messages or send an email.
 
 If you save it as cron.php, you can use a command such as the following in
 your crontab:
 
 wget -q -O - www.domain.com/cron.php  /dev/null
 
 I'm assuming you know the specifics of cron or can google for it. :)
 
 ---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
From: Jonathan Villa [EMAIL PROTECTED]

  wget -q -O - www.domain.com/cron.php  /dev/null


 Interesting... how does this fair concerning security?  So I'll have to
 have this file located in my document root, is this a good thing?  My
 current directory structure consists of several files located outside
 the doc root.  I guess I could always include it onto a page

Well, I guess it would depend upon what your cron.php does. You must be
aware that anyone can just type in the URL and run the script at any time,
not just when the cron process runs it. For example, my cron.php script
creates a mysql backup file and erases any backup files older than 30 days.
When it runs, it first checks if the backup for today was already made or
not. If it's already there, it does nothing. So, you can call this script
all you want and it's not going to mess up anything. Again, it depends on
what your script is doing, though.

Yes, it's safer to keep it outside of the webroot and call it via the
command line. This way you know it's only being called by cron and only when
you want it. It just depends on whether you can do that on your system or
not.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread Ryan Marks
Not necessarily.  You can wget /path/to/file.php or my personal preference
is not to use wget, but php directly
/path/to/php/executable /path/to/file.php

Just a thought,
Ryan

-Original Message-
From: Jonathan Villa [mailto:[EMAIL PROTECTED]
Sent: Monday, September 15, 2003 3:28 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Need to Run a PHP script using CRON or ?



Interesting... how does this fair concerning security?  So I'll have to
have this file located in my document root, is this a good thing?  My
current directory structure consists of several files located outside
the doc root.  I guess I could always include it onto a page


On Mon, 2003-09-15 at 14:49, CPT John W. Holmes wrote:
 From: Jonathan Villa [EMAIL PROTECTED]


  I have an application which creates temporary tables.  My plan is to
  remove them after a 24 hour period and only those which are have a
  created time greater than 24 hours.  That part I can do, my question is
  how will I be able to run this script which is a 2 part script.
 
  First thing I do is pull the names of the temporary tables which are
  going to be deleted from another table.  From this result set, I need to
  DROP tables as well as remove the reference to them from the first
  table.
 
  I understand that I can run PHP from the command line but this would
  require PHP to installed as a CGI which I prefer not to do.
 
  I was hoping I that I could use CRON to run this script once a day...

 You can. Create a php script that does what you want. It should not create
 any output, either log status/error messages or send an email.

 If you save it as cron.php, you can use a command such as the following in
 your crontab:

 wget -q -O - www.domain.com/cron.php  /dev/null

 I'm assuming you know the specifics of cron or can google for it. :)

 ---John Holmes...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
From: Ryan Marks [EMAIL PROTECTED]


 Not necessarily.  You can wget /path/to/file.php or my personal preference
 is not to use wget, but php directly
 /path/to/php/executable /path/to/file.php

Are you sure about that? I thought wget had to go through HTTP?

This didn't work for me, am I doing it wrong?

$ ls
cpanel3-skelmailpublic_html tmp
cpanelbranding  public_ftp  test.phpwww

$ wget test.php
--16:42:22--  http://test.php/
   = `index.html'
Resolving test.php... failed: No address associated with hostname.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread Jonathan Villa
I believe this would need php to installed as a cgi, which I prefer not
to do...


On Mon, 2003-09-15 at 15:31, Ryan Marks wrote:
 Not necessarily.  You can wget /path/to/file.php or my personal preference
 is not to use wget, but php directly
 /path/to/php/executable /path/to/file.php
 
 Just a thought,
 Ryan
 
 -Original Message-
 From: Jonathan Villa [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 15, 2003 3:28 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Need to Run a PHP script using CRON or ?
 
 
 
 Interesting... how does this fair concerning security?  So I'll have to
 have this file located in my document root, is this a good thing?  My
 current directory structure consists of several files located outside
 the doc root.  I guess I could always include it onto a page
 
 
 On Mon, 2003-09-15 at 14:49, CPT John W. Holmes wrote:
  From: Jonathan Villa [EMAIL PROTECTED]
 
 
   I have an application which creates temporary tables.  My plan is to
   remove them after a 24 hour period and only those which are have a
   created time greater than 24 hours.  That part I can do, my question is
   how will I be able to run this script which is a 2 part script.
  
   First thing I do is pull the names of the temporary tables which are
   going to be deleted from another table.  From this result set, I need to
   DROP tables as well as remove the reference to them from the first
   table.
  
   I understand that I can run PHP from the command line but this would
   require PHP to installed as a CGI which I prefer not to do.
  
   I was hoping I that I could use CRON to run this script once a day...
 
  You can. Create a php script that does what you want. It should not create
  any output, either log status/error messages or send an email.
 
  If you save it as cron.php, you can use a command such as the following in
  your crontab:
 
  wget -q -O - www.domain.com/cron.php  /dev/null
 
  I'm assuming you know the specifics of cron or can google for it. :)
 
  ---John Holmes...
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread Ryan Marks
My bad... wget does require http or ftp protocol and a hostname that can be
resolved by the server.

-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Monday, September 15, 2003 3:47 PM
To: Ryan Marks; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Need to Run a PHP script using CRON or ?


From: Ryan Marks [EMAIL PROTECTED]


 Not necessarily.  You can wget /path/to/file.php or my personal preference
 is not to use wget, but php directly
 /path/to/php/executable /path/to/file.php

Are you sure about that? I thought wget had to go through HTTP?

This didn't work for me, am I doing it wrong?

$ ls
cpanel3-skelmailpublic_html tmp
cpanelbranding  public_ftp  test.phpwww

$ wget test.php
--16:42:22--  http://test.php/
   = `index.html'
Resolving test.php... failed: No address associated with hostname.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread Pat Lashley
--On Monday, September 15, 2003 15:27:45 -0500 Jonathan Villa 
[EMAIL PROTECTED] wrote:

Interesting... how does this fair concerning security?  So I'll have to
have this file located in my document root, is this a good thing?  My
current directory structure consists of several files located outside
the doc root.  I guess I could always include it onto a page
Unfortunately command-line fetch programs seldom provide a clean
method for providing authentication info; so you probably can't
just restrict access to that script based on a userid/password.
(You might be able to do something with SSL and client certificates;
but then you need to either buy a client cert or figure out how to
set up a private certificate authority...)
So, put it in a separate directory under ServerRoot and set up a
name based virtual host with an Alias to provide access to that
dir.  Set the virtual host to reject connections from anything
except your local host.
Or use the same hostname; but have your VirtualHost listen on
a non-standard port.  Then your firewall can help block outside
access to that port.
How much that improves security depends on how you have that machine
set up.  If you are the only one with shell access; it's probably
acceptably good.  If untrusted people have shell access; then it's
not much better than just sticking it in your datadir and hoping
that nobody figures out its URL.


-Pat

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread Matt Babineau
Goto your shell and type php -i w/o the quotes. You should see the
phpinfo() output. You can pass the path to your script as a command line
variable, and it will process it. Here, read about it, I think this is
the right answer for you: http://us3.php.net/features.commandline

Matt

On Mon, 2003-09-15 at 15:41, Jonathan Villa wrote:
 I have an application which creates temporary tables.  My plan is to
 remove them after a 24 hour period and only those which are have a
 created time greater than 24 hours.  That part I can do, my question is
 how will I be able to run this script which is a 2 part script.
 
 First thing I do is pull the names of the temporary tables which are
 going to be deleted from another table.  From this result set, I need to
 DROP tables as well as remove the reference to them from the first
 table.
 
 I understand that I can run PHP from the command line but this would
 require PHP to installed as a CGI which I prefer not to do.
 
 I was hoping I that I could use CRON to run this script once a day...
 
 Any ideas?  

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Need to Run a PHP script using CRON or ?

2003-09-15 Thread CPT John W. Holmes
- Original Message - 
From: Pat Lashley [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, September 15, 2003 5:12 PM
Subject: Re: [PHP-DB] Need to Run a PHP script using CRON or ?


 --On Monday, September 15, 2003 15:27:45 -0500 Jonathan Villa
 [EMAIL PROTECTED] wrote:

 
  Interesting... how does this fair concerning security?  So I'll have to
  have this file located in my document root, is this a good thing?  My
  current directory structure consists of several files located outside
  the doc root.  I guess I could always include it onto a page

 Unfortunately command-line fetch programs seldom provide a clean
 method for providing authentication info; so you probably can't
 just restrict access to that script based on a userid/password.
 (You might be able to do something with SSL and client certificates;
 but then you need to either buy a client cert or figure out how to
 set up a private certificate authority...)

Getting off topic here, but you can specify user and password for wget. So
you could protect the file with .htaccess and provide the user/login to
wget.

The only problem is the user/password will be available when you run ps.
For a way to get around that, see the man page of wget.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php