Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Large Apache Domain Logs

Tags:

linux

apache

I am having an issue where Apache logs are growing out of proportion on several servers (Linux CentOS 5)... I will eventually disable logging completely but for now I need a quick fix to reclaim the hard disk space.

I have tried using the echo " " > /path/to/log.log or the * > /path/to/log.log but they take too long and almost crash the server as the logs are as large as 100GB

Deleting the files works fast but my question is, will it cause a problem when I restart apache. My servers are live and full of users so I can't crash them.

Your help is appreciated.

like image 304
Harry Andrei Avatar asked Mar 05 '12 15:03

Harry Andrei


1 Answers

Use the truncate command

truncate -s 0 /path/to/log.log

In the longer term you should use logrotate to keep the logs from getting out of hand.

like image 184
Kirby Todd Avatar answered Oct 19 '22 23:10

Kirby Todd