Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-06-2007, 12:50 PM   #1
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Rep: Reputation: 15
Question HDD space problem


I have a CentOS running on a remote web server. It has a 10G HDD storage space and now it's almost full.
Filesystem            Size  Used Avail Use% Mounted on
/dev/vzfs              10G  9.1G  935M  91% /
The thing is a while back i've accidentally done a 'crontab -r' instead of 'crontab -e' so all the log rotation/cleanup scripts are gone.

This being said, the logs for the domains keep growing bigger so I decided to delete the logs manually. I found the logs in /var/www/vhosts/ and i've deleted them. About 2G of logs. I used 'rm -rf'.

The problem is that the logs no longer appear when i do a 'ls -al' but space on disk isn't cleared either.

Do you guys have any idea ?

Old 11-06-2007, 01:21 PM   #2
LQ Newbie
Registered: Nov 2007
Posts: 3

Rep: Reputation: 0
Space didn't come back

Your space didn't come back because those files are still open by the processes that are writing to them.

So, restarting those processes is necessary to get back your space.

A reboot of the server is the easiest way to accomplish this. But, if you can't do it for uptime purposes, then you'll need to look through /etc/rcx.d (for whatever run level you're running at) see if you can spot the program(s) that are writing to those files, and see if you can re-run them with a "restart" or "reload" command. Or, perhaps just a "stop" and then a "start" command.

For your future information, if you ever need to delete the contents of a log file in the future that you know is still open ( you'd either know it from past experience or you can see it from "lsof") without actually deleting the file itself, you can use the following command.

$> :> logfile.log

The ":" is a null, which makes the above command put a "null" in "logfile..log"

You could do this in the future to "clean" the file, without having to shutdown the programs. Of course a better solution is to use one of the rotatelog programs, but you'd probably have to shutdown the service writing to the file first, rotate the logs, and restart the service.
Old 11-06-2007, 01:33 PM   #3
LQ Newbie
Registered: Nov 2007
Posts: 1

Rep: Reputation: 0
i more or less had the same problem. thank you for the answer!
Old 11-06-2007, 02:40 PM   #4
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
Thanks a lot.

I only had to restart ( via 'service'): httpd and mysqld and ~2.5G cleared up. Thanks for the 'null' tip, i'll use it later on.

If my log rotate crontab is gone, can i create some scripts to put null into my logs form time to time ? That should be ok, should it not ?

Thanks again.
Old 11-07-2007, 11:21 AM   #5
LQ Newbie
Registered: Nov 2007
Posts: 3

Rep: Reputation: 0
Sure, you can do that. But, you probably want some kind of way to keep and protect those log files (if this is a serious IT shop's application), at least for a while.

What I'd probably do is have a cron job that every day copies the contents of that file to some place else, an archive location.
Then, null the file,
Then exit

I've not even run it, but something like the following:


if [ -f $FULL_LOG ]; then
cp $FULL_LOG $MYARCHDIR/$MYLOGFILE.`date "+%y%m%d"`
if [ $? -ne 0 ]; then
echo error copying file $FULL_LOG to $MYARCHDIR
exit 1
:> $FULL_LOG || ( echo Error nulling file $FULL_LOG; exit 3)
echo "Archive and truncing $FULL_LOG complete"
echo "Archiving not needed: file $FULL_LOG nonexistent"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
HDD space tombiz Ubuntu 3 07-16-2006 10:25 PM
Not enough space on HDD. Rythin Linux - Hardware 9 09-25-2005 04:44 PM
X won't come up. No space on HDD inon^ Fedora 2 07-30-2005 05:29 PM
HDD Space ColdArmor Mandriva 2 03-13-2005 05:46 PM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 04:58 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration