Login   Register  
PHP Classes
elePHPant
Icontem

Log File

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Daemon  >  All threads  >  Log File  >  (Un) Subscribe thread alerts  
Subject:Log File
Summary:If the log flie is not chowned, it may cause the service to stop
Messages:1
Author:Patrick Toole
Date:2006-08-20 22:07:42
 

  1. Log File   Reply  
Picture of Patrick Toole
Patrick Toole
2006-08-20 22:07:42
The example daemon given uses:
$fp = fopen('/tmp/daemon.log', 'a');
fclose($fp);
chmod('/tmp/daemon.log', 0777);


If you use a /etc/init.d statup script, the first user that writes to the log file will be root, causing subsequent logging to fail. Here is a fix:

$fp = fopen('/tmp/daemon.log', 'a');
fclose($fp);
@chown('/tmp/daemon.log',$this->userID);
@chgrp('/tmp/daemon.log',$this->groupID);
chmod('/tmp/daemon.log', 0777);