Location: PHPKode > scripts > Daemon > daemon/TestDaemon.class.php
<?php
class TestDaemon extends Daemon
{
   function TestDaemon()
   {
      parent::Daemon();

      $fp = fopen('/tmp/daemon.log', 'a');
      fclose($fp);
   
      chmod('/tmp/daemon.log', 0777);
   }

   function _logMessage($msg, $status = DLOG_NOTICE)
   {
      if ($status & DLOG_TO_CONSOLE)
      {
         print $msg."\n";
      }
      
      $fp = fopen('/tmp/daemon.log', 'a');
      fwrite($fp, date("Y/m/d H:i:s ").$msg."\n");
      fclose($fp);
   }

   function _doTask()
   {
      static $i = 0;
   
      sleep(1);
   
      $i++;
   
      if ($i >= 30)
      {
         $this->stop();
      }
   }

}
?>
Return current item: Daemon