Php script als dienst

Aus metasec wiki
Wechseln zu: Navigation, Suche
<?php
#!/usr/bin/php4 -q
<?php
/*
 *      AGI Script for checking dialout permissions
 *      (c) Lukas Ziaja <lz@metasec.de>
 */

set_time_limit(0);
declare(tick=1);
$pid = pcntl_fork();
if ( $pid == -1 ) {
    die("could not fork");
} elseif ( $pid ) {
    exit();
} else {
    // we are the child!
}

if ( posix_setsid() == -1 )
    die("could not detach form terminal\n");

while ( !$test ) {
    so_something();
    sleep(1);
};

?>
chmod +x script_name.php
./script_name.php