LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   no changes after deleting files (https://www.linuxquestions.org/questions/linux-server-73/no-changes-after-deleting-files-4175414524/)

linuxguy08 07-02-2012 06:02 PM

no changes after deleting files
 
Hi ,

I have deleted some log files because of space crunch and after removed I still see the same percentage of space as how it was earlier before removal. So can you suggest what could be the reason and how to fix it out?

Thanks

---------- Post added 07-02-12 at 06:03 PM ----------

Sorry forgot to mention the server details
it it centos 5.2

etech3 07-02-2012 06:35 PM

Code:

updatedb
and then search for the files again.

linuxguy08 07-02-2012 06:54 PM

so updatedb will make changes.

my questions , even after removal of log file, I see the same filesize in the var , no changes has been taken effect with
df -h

etech3 07-02-2012 07:05 PM

Removed a log file or cleared it?

So how did you remove it?

If you wanted to clear a file:
Code:

cat /dev/null > aptitude
Check the file size before and after.

etech3 07-02-2012 07:19 PM

Try looking for zero size files:

Code:

find /var/log -type f -size 0k
I just make a script and clear the log after review.

chrism01 07-02-2012 07:30 PM

For log files, you should really use the logrotate tool http://linux.die.net/man/8/logrotate, see /etc/logrotate.d (dir).

FYI, if a process has a file open, the the disk space is not returned after deletion until the file is released http://linux.die.net/man/2/unlink i.e. the file just becomes invisible to ls, find cmds etc.
You shouldn't normally delete an open file anyway; see lsof http://linux.die.net/man/8/lsof fuser http://linux.die.net/man/1/fuser

TobiSGD 07-02-2012 07:33 PM

Quote:

Originally Posted by etech3 (Post 4717580)
Removed a log file or cleared it?

So how did you remove it?

If you wanted to clear a file:
Code:

cat /dev/null > aptitude
Check the file size before and after.

You can shorten that to
Code:

>logfile

etech3 07-02-2012 07:39 PM

Thanks TobiSGD, I'll add that to my script!

anomie 07-03-2012 12:39 PM

Quote:

Originally Posted by chrism01
if a process has a file open, the the disk space is not returned after deletion until the file is released

Exactly. From the sounds of this problem, you may have just unlinked a file that is still being written to.

Try:
Code:

# lsof +L1 /var | egrep 'PID|deleted'
(That is a root prompt. So run it as root.)

linuxguy08 07-03-2012 05:27 PM

Thanks lot!!


All times are GMT -5. The time now is 06:49 PM.