How to kill/close log files that are open through lsof grep deleted?

6,703

Solution 1

looks like pid 20583 is keeping open the file. So search for it

ps aux | grep 20583

See what process is holding it open and restart the process or kill it.

Solution 2

If this is not a production system, just restart/kill postgres.

I'll check later for your answer, because there's a way to empty these files if you can't restart the application right now and you REALLY need the disk space urgently, but I wouldn't recommend it from the start.

Share:
6,703

Related videos on Youtube

KyelJmD
Author by

KyelJmD

Software Engineer

Updated on September 18, 2022

Comments

  • KyelJmD
    KyelJmD almost 2 years

    I have a deleted a large log file from our servers. so I executed this command to validate.

    lsof -nP | grep '(deleted)'
    

    enter image description here

    and this showed up.

    how can I permanently delete the results fo this lsof? I need to recliam the needed space on our hardrive

    • Gmck
      Gmck over 8 years
      Have you tired restarting postgres?
    • KyelJmD
      KyelJmD over 8 years
      @gmck I tried executing sudo /etc/init.d/postgresql stop but the file still persists/results still persists