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
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityYou can use this:
>error.log
(typed just like that - an empty output redirection)
or
truncate -s0 error.log
sudo
takes effect. Or you can do sudo bash -c '>error.log'
May 19, 2014 at 10:56
echo "some words" > output.txt
but nothing is going in.
Oct 25, 2018 at 16:46
You'll confuse the daemon. Erase the file then send SIGHUP
to nginx.
truncate
are atomic, so as long as no seeking is going on (especially if the only operation that's occurring is appending) it shouldn't be disruptive.
Dec 4, 2010 at 3:25