How do erase the contents of a error.log file but keep the file intact

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

2 Answers

You can use this:

>error.log 

(typed just like that - an empty output redirection)

or

truncate -s0 error.log 
7

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

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like