Make sure there's no application/program that keeps the log file open even though it's deleted.
To release the disk space, don't delete the file but rewrite it with zero size.
Yes, after you have deleted the file there is little you can do to recover the allocated space apart from killing and restarting the process(es) that have the file open.
As RudiC points out you are better off writing zero size to the logfile eg:
Or
As a long-term solution you should consider using the logrotate daemon to keep your logfile sizes down.
Last edited by Chubler_XL; 12-30-2014 at 06:37 PM..
Yes, after you have deleted the file there is little you can do to recover the allocated space apart from killing and restarting the process(es) that have the file open.
As RudiC points out you are better off writing zero size to the logfile eg:
Or
As a long-term solution you should consider using the logrotate daemon to keep your logfile sizes down.
And don't be surprised if that doesn't work.
There are ways for applications to write to log files that create problems with that method. One of them is redirecting stderr/stdout by using ">>" shell redirection.
If those methods are used, filesystem-specific features can come into play.
There's a reason why operating systems provide robust, scalable logging facilities. Scalable logging is not something that can be done reliably without serious work.
So if your app is not well-designed, you may be stuck with "kill the app, clean up the log file, restart the app".
Hello,
OS version is Red Hat Enterprise Linux Server release 6.5 (Santiago).
In one of the filesystem some old files post clone are not getting removed even with 'rm'
# ls -ltr | grep meagpd_62.dbf
-rw-rw---- 1 oracle oinstall 34358697984 Sep 1 08:46 meagpd_62.dbf
# rm... (7 Replies)
Bonjour,
I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things.
The script use the following technique :
tail -fn0 $logfile | \
while read line ; do
... some stuff
done
First one, I'd like a way to end the monitoring script if a... (3 Replies)
Hi Team,
Have to write a shell script to pick only 1 hr logs from the generated logfile and send it to other logfile.
Thanks & Regards,
Indu (3 Replies)
I there a way to figure out how part of a logfile got deleted? I know unix does not have a date created date so that makes things very difficult to tell if the file got deleted or not. Several thousand lines of my .bash_history somehow got deleted. I still have this in my .bashrc so I don't... (0 Replies)
Hi,
I have a lengthy shell script and when I try to run it, It takes a lot of time and for about 25-30 mins and outputs this message xrealloc: cannot reallocate (23523666) bytes (0 bytes allocated). Along with this it is also displaying two other error messages. One is it is saying the... (3 Replies)
I have a disk space issue on one of my unix servers.
it is showing 98% full.. i found the offending folder and removed it. but i have not reclaimed the disk space.
is there another command that i need ?
thank you in advance for any assistance. (4 Replies)
Good afternoon! Im new at scripting and Im trying to write a script to
calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
hi
iam new of the ksh script.iwant in formation of how to call in logfile in
ksh scripts. if the meaning in ksh.
please help me
thanks
naveen.g (1 Reply)
hi friends
I need a shell script which will do the following Task
Enter the month :
if you enter 1 then it ll show you last 1 month's (starting from today).log file in the current directry.
if you enter 4 then it ll show you last 4 month's (starting from today).log file in the current... (2 Replies)
I am using Posix shell to write a script. The problem I am having is that when I use the read command to go through a file I lose the tabs. How can I keep this from happening? (1 Reply)