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! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-06-2007, 11:50 AM
|
#1
|
Member
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140
Rep:
|
HDD space problem
Hey,
I have a CentOS running on a remote web server. It has a 10G HDD storage space and now it's almost full.
Code:
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/domain.com/statistics/logs 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 ?
Thanks.
|
|
|
11-06-2007, 12:21 PM
|
#2
|
LQ Newbie
Registered: Nov 2007
Posts: 3
Rep:
|
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.
|
|
|
11-06-2007, 12:33 PM
|
#3
|
LQ Newbie
Registered: Nov 2007
Posts: 1
Rep:
|
i more or less had the same problem. thank you for the answer!
|
|
|
11-06-2007, 01:40 PM
|
#4
|
Member
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140
Original Poster
Rep:
|
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.
|
|
|
11-07-2007, 10:21 AM
|
#5
|
LQ Newbie
Registered: Nov 2007
Posts: 3
Rep:
|
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:
---WARNING UNTESTED - FUNCTIONAL PROTOTYPE ONLY ---
#!/bin/bash
$MYLOGDIR=/mydir
$MYARCHDIR=/myarchivedir
$MYLOGFILE=mylogfile.log
$FULL_LOG=$MYLOGDIR/$MYLOGFILE
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
fi
:> $FULL_LOG || ( echo Error nulling file $FULL_LOG; exit 3)
echo "Archive and truncing $FULL_LOG complete"
else
echo "Archiving not needed: file $FULL_LOG nonexistent"
fi
|
|
|
All times are GMT -5. The time now is 04:34 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|