delete a very large file from UFS partition

I have a remote production server, where 40GB slice is allocated for var:
Code:
/dev/ad1s1f     40G     40G   -4G   110%    /var

Filesystem for /var partition is UFS and it's mounted with local and noatime options. There is a 37GB log file in the /var partition. As it's so huge and there seems to be somesort of capacity overload already, is it safe to delete this large file by just doing:
Code:
rm -rf /var/log_file

If not, please give other suggestions/warnings ;)
 
Or just truncate the file.

# : > /var/log_file

This will free up the space even if there is something that is currently writing to the file.

That's colon, greater sign, name of log file.
 
fronclynne, I have already killed this logging process so the file will not get bigger.

gordon@,
could you please explain this
Code:
# : > /var/log_file
..command a little? As I understand, this redirects( > ) colon( : ) into the /var/log_file, thus writing everything in this /var/log_file over(there will be only this colon in /var/log_file). Am I correct? Or is colon some sort of special character?

jb_fvwm2,
as I have stopped the logging command, I'll go with this /bin/rm -v /var/log_file command ;)
 
[cmd=]> /var/log_file[/cmd] or [cmd=]cp /dev/null > /var/log_file[/cmd] is enough, really.
 
DutchDaemon said:
[cmd=]> /var/log_file[/cmd]

Not from csh/tcsh, unfortunately:

Code:
% > /var/log_file
Invalid null command.

or [cmd=]cp /dev/null > /var/log_file[/cmd] is enough, really.

Careful, this could turn into "how many ways are there to do this". :)

m4rtin, see this:
# man sh | less "+/null command"
 
Colon is a null command in bourne and c-style shells. As such, the output of the command (nothing) is then redirected to the file after it is truncated. I suppose using # cat /dev/null > /var/log_file would also work.
 
gordon@ said:
I suppose using # cat /dev/null > /var/log_file would also work.

It would never finish as there will be no end-of-file ;)
 
SirDice said:
It would never finish as there will be no end-of-file ;)

Sure it'll finish. /dev/null is nothing but EOF's. You are thinking of /dev/zero which will keep going until the end of time (or you fill up your disk).
 
DutchDaemon said:
cp is the way to go! (please don't use mv there ...)

I wouldn't recommend the command you cite:

% cp /dev/null > /var/log_file

This will produce an error (but will still truncate the file since it doesn't put anything to stdout, just stderr).

At that point using % : > /var/log_file is the same. But so is % true > /var/log_file or % false > /var/log_file or % /path/to/command/with/null/output > /var/log_file for that matter.
 
gordon@ said:
I wouldn't recommend the command you cite:

% cp /dev/null > /var/log_file

This will produce an error (but will still truncate the file since it doesn't put anything to stdout, just stderr).

Yeah, that was a brain fart. It should be [cmd=]cp /dev/null /var/log_file[/cmd]

There's also [cmd=]echo > /var/log_file[/cmd]
 
Back
Top