Hi,
Recently I started using PHP as a shell scripting language (and not only as a web scripting language). For an application I'm developing at work I needed to write some sort of daemon - a program that constantly runs in the background and executes a certain action at a given date/time. I know I could do that with a cronjob, but I previously noticed that cron daemons sometimes hang and stuff...
Anyway, I started searching the archives here and found that PHP does not support fork(). Well, I wanted to point out that there's another method of writing some sort of daemon. You can write your program in an endless loop, like:
while (1) {
<do something>
sleep (30);
}
And then launching your shell script with
nohup php -q -f <yourscript>.php
That will execute the script and keep it running, even if you log off.
I hope that provides a valuable alternative for those who wanted to write some sort of daemon and couldn't find how...
Ciao !
Sven Delmeiren
E-Zone Internet Solutions