1832504 Members
4532 Online
110043 Solutions
New Discussion

/var full, cannot rm

 
Ceesjan van Hattum
Esteemed Contributor

/var full, cannot rm

Hi,
My /var is 100%, due too a many many files in /var/tmp.
I'd like to rm /var/tmp/*, but there are too many arguments to use a "*".
ls : Too many arguments
rm : Too many arguments
ls | xargs -l rm doesn't seem to work either.
What to now ?

Regards,
Ceesjan
9 REPLIES 9
Ian Box
Advisor

Re: /var full, cannot rm

Try:

for i in /var/tmp/*
do
rm $i
done

Regards,

Ian
john korterman
Honored Contributor

Re: /var full, cannot rm

Hi,
you could use the find command, e.g.:
# find /var/tmp/ -type f -name "whatever_with_wildcard" -exec ls -l {} \;
And if you get the correct output, substitute ls -l by rm.

regards,
John K.
it would be nice if you always got a second chance
Robert-Jan Goossens
Honored Contributor

Re: /var full, cannot rm

Hi CeesJan,

find /var/tmp -mtime +7 | while read LINE
do
rm $LINE
done

Hope it helps,

Robert-Jan.
John Palmer
Honored Contributor

Re: /var full, cannot rm

Try find with -exec:-

find /var/tmp -type f -mtime +X -exec rm {} \;

Where X = a number of days old.

Alternatively, you can still use rm but limit the number of files by specifying a less general argument. Something like:-

rm a* # remove all files starting with a
rm b*
rm aa*
rm bb*

etc depending what filenames you have.

Regards,
John
Ravi_8
Honored Contributor

Re: /var full, cannot rm

Hi

#cd /var
#rm -rf tmp
#mkdir tmp
never give up
Ceesjan van Hattum
Esteemed Contributor

Re: /var full, cannot rm

Thanks the respons.
All options i already found myself, but the real solution was to find the processes which generate these files.
It seemed that i had more than 10 fbackup processes running.
By killing these fbackups, the /var was automatically reduced to 63%. The amount of files decrease just enough to let my wildcard-expension (*) work again.

Case closed
Thanks,
Ceesjan
Colin Topliss
Esteemed Contributor

Re: /var full, cannot rm

A note of caution here!

Don't forget that many system daemons/software place their lockfiles in /var/tmp (for example RaidManager). You don't necessarily want to remove everything or you could delete something the system needs.

I would look to see what is in the directory first using Robert Jan's solution (but echo rather than rm the line) then use John Palmers idea to delete blocks of files.
Robin Wakefield
Honored Contributor

Re: /var full, cannot rm

Hi Ceesjan

Check against a current /var/tmp file by running lsof - this will identify the process associated with the file.

rgds, Robin
Steven E. Protter
Exalted Contributor

Re: /var full, cannot rm

You may have files loaded in the /var folder prior to mount.

Boot your system to single user mode.

shutdown -ry now

interupt the boot process when prompted

bo Y to interact with the IPL

hpux -is

Boots to single user mode, mounts nothing.

cd /var

There should be nothing there. If there is, list it and delete it or possbily move it somewhere else.

You can issue manual mount commands in single user mode.

mount /home

Then move the offending files there if applicable.

If files have been copied into /var while not mounted, they wont show up on a ls after a filesystem is mounted on the folder. Thus the files appear hidden and are tough to find.

Its happened to me a few times with flaky disks and finger mistakes.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com