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
You 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'
Commented
May 19, 2014 at 10:56
echo "some words" > output.txt
but nothing is going in.
Commented
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.
Commented
Dec 4, 2010 at 3:25