scripting - Appending multiple entries to an output file with a crontab using php? -


I am writing a script in PHP where I log in system uptime, current time and the quantity of users in a log file system These have been done, and are continuously updated through a crontab.

I need help for this, that I would like to submit the updates in the file and will be continuously added. Until now, whenever my script is executed, the latest update overwrites the previous update.

What I have done is that I tried to declare an array of entries and as I repeat through the array again, press the contents of the update in the array (this half-baked There may be a bit of logic in my part).

My code:

  $ fileName = '../so-and-so directory / output.log'; $ Dt = date ('m / d / y'); $ Time = date ('h: ii'); $ Data = shell_xax ('uptime'); $ Uptime = explosion ('up', $ data); $ Uptime = Explosion (',', $ uptime [1]); $ Uptime = $ uptime [0] ','. $ Uptime [1]; $ User = system ('w', $); $ Array = new splfixedArray (3); $ FileLog = fopen ($ fileName, 'w'); $ FileString = "Date:" $ dt. "\ N". "time:". Time "\ N". "system uptime ". $ Uptime ". \ N". "User" "$ users; foreign currency (dollar array as $ entry) {array_push (file_put_contents ($ fileName, $ fileString));} Fclose ($ fileLog);   

It seems that the solution is very simple, but I am missing it. Will someone give me a clue?

"W" The filemade file will be sorted, instead of the "a" attachment at the end. See fopen (3) or PHP documentation for details.

In addition, File_put_contents () delete the file Instead try fwrite () .

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -