1

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.

1
  • 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, 2013 at 17:06

1 Answer 1

1

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.

3
  • To add: The term is 'log rotation'. A quick search for 'log rotation nginx' reveals LogRotation on nginx's website.
    – user143703
    Jun 12, 2013 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, 2013 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 Jun 13, 2013 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .