> I need to have some task performed all the time in the background
(database
> task etc.)
> How is this possible with PHP. I do not have direct access to the OS (can
> not make an application to run directly under linux). Is it possible to
have
> a PHP script execute all the time in some way.

Hmmmm.

Do you have telnet or SSH access, and can you install a "cron" job?...

Log in and do like this:

crontab -l

(That's an L for List, not 1)

This will list your (probably non-existant) cron jobs so far.

If that works, odds are that reading:

man 5 crontab

will have you pretty much hooked up on the "doing something regularly"
part...  Or at least, you'll see how it could maybe work once you figure out
all those *'s and stuff. :-)

Then you have to ask yourself, "Self, is PHP installed as a CGI binary
anywhere on this thing?"  Cuz if it is, it's way more better from a purist
perspective...  So, try this:

find / -name php -print 2> /dev/null | less

You may wanna take a coffee break right about here...  It's searching your
entire ISPs hard drive for the PHP binary...

Now, if that turns up a file that looks like it might be the php binary...
Do this:

ls -alsh XXX
where XXX is the thing you found and make sure it's a nice big file (a meg
or two) and not just some directory or something.

If it is, you can write a PHP script like this:

#!/full/path/to/php -q
<?php
    #your code here
?>

And then you can do:
chmod 775 myscript.php

Once you do *that* you can just slide /full/path/to/myscript.php right there
into your cron list using:

crontab -e

You'll be in an editor, and you can put in something like this:
0 1 * * * /full/path/to/myscript.php
and save it.
This one fires off at 1 am, every day.

Now, if you never did find the PHP binary, all is not lost.  There might be
"wget" on your server, and you can use crontab to make that *surf* to your
PHP page every day, still using crontab.

Now, even if you can't find that wget thingie, you almost for sure have
"lynx" on your server, and you can use *that* to surf to your page every
day.

PHP as a CGI (the first choice) is more efficient, wget after that, and lynx
last of all.

Still, they'll all get the job done.

Don't worry if it takes awhile to get the hang of this cron stuff -- Took me
months to figure it out the first time around (well, I had some editor
problems mixed in there too).  Once you do one of them, though, you find all
sorts of nifty things that it's handy for.  You don't want to get carried
away, of course, cuz cron is no magic bullet.  Each of those jobs you run
takes up some work, and they can add up if you get silly about it.

Still, all sorts of low-level maintenance and menial tasks can be automated
this way, and setting it up is not much harder than doing the task once.
But once it's going, you can cross it off your ToDo list practically
forever.

I know that was kinda ramblin', but that's the way I was feelin'  Hope it's
okay.

Don't miss the Zend Web Store's Grand Opening on January 23, 2001!
http://www.zend.com
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to