Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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?
You can use this:
(typed just like that - an empty output redirection)
truncate -s0 error.log
sudo bash -c '>error.log'
echo "some words" > output.txt
You'll confuse the daemon. Erase the file then send SIGHUP to nginx.
Required, but never shown
8 years ago