Avatar of Nura111
Nura111

asked on 

How to save a daily log file in linux frpm a php script?

Im runing a script as a cron job every ten min. I want to create a daily log file for the results I thought its working but Im looking at monitor log and I only see one file for one date
why it is not creating a file for every day??


thank you!

$ourFileName = "/home/nurit/monitorTest/monitorLog"; 
	 $arg = (file_exists($ourFileName.date("Ymd")) == true ? "a+" : "w" );
	 $ourFileHandle = fopen($ourFileName, $arg) or die("can't open file");
	 $currDate = date("d/m/y : H:i:s", time());
	 $file_contents = "\nThe server is down for: ".$host." on D:".$currDate;
	 fwrite($ourFileHandle,$file_contents);
	 fclose($ourFileHandle);

Open in new window

LinuxPHPLinux OS Dev

Avatar of undefined
Last Comment
Hugh McCurdy

8/22/2022 - Mon