Can I delete error log files in apache. Will it cause an issue? [duplicate]

If you must clear the log file, do

cp /dev/null /var/log/file

or

echo > /var/log/file

That truncates the file without closing any open file handles.

Edit: Using logrotate to deal with the files is the better long-term solution. Truncating the file should be an emergency measure.


I would rather recommend going for logrotate in stead of deleting the old log files straight away. You might need them later for debugging something or to find out the pattern when system was running fine, for comparison purpose.

There is a reason that backup and recovery are so sought after. However if this is not any production server or something important, I wouldn't worry about deleting them.