28

I want to erase the contents of the file error.log (nginx error log file), but I don't want to actually delete the file.

is this possible?

running ubuntu

user27449
  • 6,770
  • 22
  • 64
  • 86

2 Answers2

74

You can use this:

>error.log

(typed just like that - an empty output redirection)

or

truncate -s0 error.log
Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
2

You'll confuse the daemon. Erase the file then send SIGHUP to nginx.

Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247