Commands

CommandsDescriptions
lsof /path/to/file/or/foldershows which service opens whiche file descriptor

Removing content from file without impacting the software

$ cat /dev/null > /path/to/file
$ truncate -s 0 /path/to/file
$ :> /path/to/file
$ > /path/to/file

Recover free disc space from deleted file with a referencing process (without restart)

finding the file descriptor on your disk

$ find /proc/*/fd -ls 2>/dev/null | grep '(deleted)'

check what line is the right one, if you have more than one check all lines and processes now you should see something like this

$ /proc/[0-9]+/fd/[0-9]+ -> /path/to/file

if you have space you can backup the original file by copping it like:

$ cp /proc/[0-9]+/fd/[0-9] /tm/copy_path_to_file

now you know the path of the file descriptor and you can start to replace the content with some null values like above

if you dont care how much files there in, you can use that one:

$ find /proc/*/fd -ls 2> /dev/null | awk '/deleted/ {print $11}' | xargs truncate -s 0

This will do the same as abve but you have to confime every file with yes

$ find /proc/*/fd -ls 2> /dev/null | awk '/deleted/ {print $11}' | xargs -p -n 1 truncate -s 0