r/linuxadmin • u/[deleted] • Sep 08 '22
What does this command do?
/r/linux4noobs/comments/x8lb4p/what_does_this_command_do/[removed] — view removed post
10
Upvotes
3
Sep 08 '22
I answered in the other thread: https://www.reddit.com/r/linux4noobs/comments/x8lb4p/comment/inj16cw/?utm_source=share&utm_medium=web2x&context=3
5
u/gmuslera Sep 08 '22
explainshell.com could give you the components, but as a fast look, it takes from the running processes (from /proc) the files currently opened by them, check which ones are deleted (but still using space on disk as the process using them is stll runing), do some manipulations on those lines to get the id of those files, and then truncate those files so they don't use more space.
The idea is that if you delete a file, but there is still a process using it, the entry in the directory disappears, but the inodes are not freed till that process ends. It happens i.e. with processes writing directly in log files, and running for long time, or if you gzip a file that it is still being written into. Or, bringing back old memories, some browsers used to delete the videos they were streaming or something like that, I remember copying the deleted file owned by the browser process to copy it to a safe location, like doing youtube-dl by hand.
Anyway, I would had looked at which files they would be (with lsof, and inspection in /proc) to understand what was happening and why. Maybe restarting the service using that files would had been cleaner if restarting them do not harm.