Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On nginx: if I open the error log, select all (in emacs) and cut, save, php errors stop logging to that file completely. If I restart nginx, they begin logging again. If I delete the files line-by-line (Control+K), the errors still save as expected. There are no changes anywhere to the file ownership or permissions. What could that "select all"+cut be doing that causes the errors to stop logging?

Thanks for any leads.

share|improve this question
    
Probably either the save bit or just using emacs, it may leave the file open/locked - have you tried doing this with vi and not saving? –  Chopper3 Jun 12 '13 at 17:06

1 Answer 1

up vote 1 down vote accepted

The issue is not specific to nginx. It can happen with any logging, and is common with syslogs. The file is open for writing by the app or syslog. You should not open it. Copy the file to a new location and open it, or stop the service (unlikely you want the second option).

Log files have a purpose in giving you an unbiased trace of what has happened on the system. It is bad style to edit them. You never know what someone will ask for in the future, and if you've changed the log content, you can't find evidence, debug problems, etc.

Professional sysadmins never edit log files, unless there are issues like disk filling up and then we are loosing logging data anyway.

share|improve this answer
    
To add: The term is 'log rotation'. A quick search for 'log rotation nginx' reveals LogRotation on nginx's website. –  yoonix Jun 12 '13 at 17:58
    
He didn't say he was rotating logs. He said he was editing the error log. But if you are log rotating, a similar issue can come up with the log file not getting updated. Logrotate is a common tool to automate this in cron and then the postrotate section for the logrotate config can include the kill command referenced by yoonix's link. –  labradort Jun 12 '13 at 18:43
1  
Thanks, this makes sense, good to know that this is the way it's supposed to work. Just one minor tweak, labradort - she :p –  user2044774 Jun 13 '13 at 13:12

Your Answer

 
discard

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.