0

My directory /var has reached 92% usage and I need to clean it. I am trying to identify where I should point at.

I know that df -k gives me the % of allocation from /, but how can I get the same info inside /var? How do I drill down to find the directory or directories that are taking up the most space?
I am trying df -k /var but it is not outputing % allocation from all directores inside.

I am using HP-UX. It is an old machine from work. It has no graphical UI as fas as I know.

jet2016
  • 133
  • 4
  • Is /var a separate partition to /? – ctrl-alt-delor May 04 '20 at 21:28
  • I have no restrictions in permissions. It is all in one partition. Problem is I cannot install anything there. I can only user unix hp-ux commands to find the files that are taking up space inside /var. – jet2016 May 04 '20 at 21:33
  • I would think that du is standard. But is not graphical (this is a good best suited to a GUI). Give it a go, it is not too bad. You can get a pretty good idea from the numbers. And you don't need to install to run a program. – ctrl-alt-delor May 04 '20 at 21:40
  • I have used also du it is good option. How can I order the output of du -k /var based on size? With the most size at the end. – jet2016 May 04 '20 at 22:05

3 Answers3

0

df gives basic information on disk/partition usage.

du gives detailed usage by scanning a directory tree. It needs permission to read and cross the directories that it scans, and is slower (But not too slow).

There are also some excellent graphical tools that do the same as du: e.g. baobab, k4dirstat, and others.

0

A good command line to start with:

du -kx /var | sort -rn | more

It will list the amount of space contained by each directory, sorted by size in decreasing order. Of course /var itself will be at the top since it contains everything else, but with this list you can easily identify the longest branches of the directory tree that contain the largest amount of data. Those are good candidates for finding the largest things that need to be cleaned up.

Note that HP-UX has system logs under /var/adm/syslog/ and the default configuration does not necessarily include any form of log rotation, so the log files may have grown huge. But these are text files that can be freely truncated to zero size if you wish.

You should not remove any active logfiles as syslogd won't automatically create new files if an expected log file is missing, but truncating them to zero size with e.g.

> /var/adm/syslog/syslog.log

is fine to do.

The sam menu-based administration tool has a function for automatically truncating the /var/adm/wtmp* files (the history of previous logins) in a way that saves the most recent few weeks of history, I think. These files use a binary format that is not easy to edit manually, but if you don't care about maintaining information on previous logins, truncating them to zero size is a valid option too.

telcoM
  • 96,466
  • Yes, I was investigating further and I also found that sort is probably the best option in my case. Very grateful for your answwer and also the other contributor was helpful. – jet2016 May 05 '20 at 07:42
0

Use du -sk /var to obtain a summary of every directory under /var, in kilobytes.

Just an advice, a good starting point for cleaning up space will be:

# cleanup -c 2 

It will remove patches that have been superseded two times.

Look for big files under /var/adm, for instance wtmps gets big sometimes and can be safely emptied by doing:

# :> wtmps
manolonte
  • 154