and tags as well as any //whitespace. ?> LABORatorio Revelli - WHIP Data House As the subject mentions, is fwrite method atomic in PHP? What I mean //> by that is, does fwrite function acquire an implicit lock while //> writing or do I need to explicitly acquire an EXCLUSIVE lock on the //> file before I call fwrite? // //That depends on your mode. If you opened the file in append mode, then //yes, it is atomic. On some operating systems that may or may not be //true over network filesystems like NFS if you are writing more than a //block size, but if it is a local fs and you are in append mode, you can //count on it being atomic. If you are not in append mode, then it is not //atomic at all. // //> The problem I am having is that, I want to track user requests by //> logging simple request parameters such as user IP, request URI, etc. //> instead of inserting into the db for avoiding overheads. And I will //> have a cronjob read this data around midnight and write it into the //> database (when there is little load on the server). // //For straight logging like this you should be able to simply append to //the log file and thus your fwrite will be atomic. */ fputs($handle, $ln); } if(!isset($HTTP_COOKIE_VARS["whip-session"])) { $handle = fopen($fn_today, "a+"); $line = "[" . $_SERVER['REMOTE_ADDR'] . "] | [$uid] | ". date("YmdHis ") . " | [" . $_SERVER['HTTP_USER_AGENT'] ."]\n"; atomic_fwrite($handle,$line); fclose($handle); } ?> sorry, you need frames to browse this site