Answer the question
In order to leave comments, you need to log in
How to switch writing to file via inode?
Good evening!
Please tell me a hypothetical situation.
Conventionally, there is a web server that writes the standard access.log log, and it so happened that this file filled up all the space on the server.
There are 2 ways, for example, delete this file and reboot the web server, or you can create the same file and transfer the entry to it via inode.
But I did not find exactly how to do this from a practical point of view or googled badly.
Prompt, please, commands, I will also be glad to the literature where I can learn about it.
Or is it enough that ln access.log new_access.lgo and rm access.log?
In fact, they will have the same inode, but it looks somehow ...
Answer the question
In order to leave comments, you need to log in
You can null out the contents of the file.
You can send SIGUSR1 to the server, if it knows how to handle it, so that it reopens the files.
Once "sober" the file name (path) in the inode, the server writes in the inode. You can rename the file and then kick the SIGUSR1 server or restart.
For the future - configure logrotate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question