I've been facing an issue that while using lsof | grep deleted command, I got the following result:

sendmail  11633  smmsp    3uW     REG                8,7    329818112    8119977 /var/spool/clientmqueue/dft4CCv1K5011633 (deleted)
tcpdump   11759   pcap    4w      REG                8,7 446113333248   41846283 /var/kalsym/logs/CAPTimedOUT_monitor/capAbort_2015-05-12_17-57-01.pcap (deleted)

Then I follow this procedure.

cd /proc/11759/fd
> /proc/11759/fd/4

but after that, no effect has been observed on /var size. I searched a lot on the Internet regarding this issue and tried all possible ways, but in vain. Please suggest me the way to overcome this issue.

  • You can just do kill 11759. Or how about truncate -s0 /proc/11759/fd/4? – yaegashi Feb 1 '16 at 12:12

You need to kill the process in order to free up the disk space. In future you can truncate the file using

    echo "" > file_name

instead of deleting the file, if the file is being used by any running process.

  • 2
    echo "" does write a newline to the file. To truncate it use :> <file> or echo -n > <file> (if supported). – Marco Feb 1 '16 at 12:45
cat /dev/null > /proc/PID/fd/4

This will also clear the contents of a file

cp /dev/null filename
  • 2
    No it won't. It will update the timestamp on the file, but will leave the contents unaltered. It will create an emtpy file if there was not one there already though – Eric Renouf Feb 1 '16 at 15:34
  • Eric is correct. Touch will not clear the contents of the file. My bad. – Abdiel Rosario Feb 1 '16 at 15:38
  • Still not quite, that would try to execute filename and redirect it's stdin to be from /dev/null. You can look at the comment from Marco to see an example of how to use redirection to do this (it works by running an "empty" command : and redirecting the output of that into the file) – Eric Renouf Feb 1 '16 at 15:40
  • Refer to linkDifference between cat and '>' to zero out a file Answers from Patrick and Stéphane Chazelas – Abdiel Rosario Feb 1 '16 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.