You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
515 B
25 lines
515 B
14 years ago
|
#!/usr/bin/php -q
|
||
|
<?php
|
||
|
|
||
|
set_time_limit(0); // Remove time limit
|
||
|
|
||
|
if (pcntl_fork()) { // Fork process
|
||
|
printf("Daemon running.\n");
|
||
|
} else {
|
||
|
$sid = posix_setsid(); // Make child process session leader
|
||
|
|
||
|
if ($sid < 0) {
|
||
|
exit();
|
||
|
}
|
||
|
|
||
|
while (true) {
|
||
|
$outfile = fopen('daemon.log', 'a+');
|
||
|
fwrite($outfile, time() . " Hello World via command line daemon!\n");
|
||
|
fclose($outfile);
|
||
|
|
||
|
sleep(1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|