Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Today my server was unresponsive to HTTP requests and it looks like the cause was that nginx went down because when I restarted nginx, it worked again. I wanted to take a look in the error log to see what went wrong but it's 97 gigabytes:

-rw-r----- 1 www-data adm  106614104064 Mar 23 00:52 error.log

Can anyone recommend a way to manage this kind of log? I obviously can't download it from the server and when I try to open it in nano/vi the terminal just goes unresponsive. I was thinking of also running a log parser on it and using that but I dare say that'd take a long time on a file that's almost 100 gigabytes.

Edit: After some more digging it seems the reason nginx crashed was because its log took up all available disk space, so it must've been an error that kept making nginx log to the error log, because my site doesn't get a lot of traffic.

share|improve this question
up vote 2 down vote accepted

You can get the last 100 lines of the log with the following command:

tail -100 error.log

Or to save them to a new file:

tail -100 error.log > error-100.log

You can save any number of lines you need instead of 100, then simply delete the original file

Moreover, to avoid such situation again you should start configuring log rotation for Nginx

share|improve this answer

I'd suggest truncating the file with : > /path/to/error.log. That will zero the file and you won't have to restart your nginx. From there, you can run tail -f /path/to/error.log to see why it's growing at such an accelerated rate.

share|improve this answer
Truncating a file with such big size ain't a good idea, it will kill the performance. Deleting the file then telling Nginx to re-read its logs files by sending a kill -USR1 to the master process would be the solution to go with to avoid Nginx restarting – minniux Mar 23 '13 at 2:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.