Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php.log: what is the proper way to clear log file?

Tags:

php

unix

logging

I'm troubleshooting a php log file that has expanded way too rapidly and used up a lot of disk space.

What is the best way to clear a log file?

is it a problem to simply delete the log file? And will that log file be recreated as php tries to write to it?

like image 956
Kristian Avatar asked May 09 '12 22:05

Kristian


3 Answers

It is entirely safe to just delete the php.log file. It will be auto-created the next time it is needed.

like image 107
Travis Weston Avatar answered Sep 30 '22 12:09

Travis Weston


On Linux you can do :

cat /dev/null > /var/logs/php.log   
like image 23
Giorgi Bigvava Avatar answered Sep 30 '22 11:09

Giorgi Bigvava


On Mac OS X 10.6 I deleted /var/log/apache2/error_log. Minor panic when it didn't re-appear upon refreshing my page. Just had to restart apache by going through the Sharing settings. Now she's back.

like image 37
Ryan Shirley Avatar answered Sep 30 '22 12:09

Ryan Shirley