[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: how to i return a filesize to "0"....?



At 11:57 AM 8/2/99 +1000, you wrote:
>how do i return a filesize to 0? That is, i want to cleanup my HUGE log
>files from taking up room, but rather than getting rid fo the files i
>want to be able to clear all their contents out and returm their size
>value to 0 - is this possible and if so how do i do it..?

Easiest way is to delete and recreate the file. You could probably do this
in one fell swoop with a shell script, but if you're so desperate for space
that you can't wait for a logrotate event you may not want to store the
script on your hdd ;)

Assuming you want to make file "/var/log/X" zero length you'd do (as root,
or somebody with write permission for this file):

rm /var/log/X
touch /var/log/X

The first line removes the original file, the second creates a new empty
file. You may also want to check the permissions in advance so you can
reset them afterwards if necessary (e.g. for most system logs you would
want to execute the third command:
chmod 600 /var/log/X

Needless to say in a shell script or function definition you'd simply put X
in as the first command line arg.
--

Who is this General Failure, and why is he reading my hard disk?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]