Operating System - HP-UX
1825742 Members
2366 Online
109687 Solutions
New Discussion

House keeping the var directory

 
jason-dr
Occasional Contributor

House keeping the var directory

Hi everone,
I wish everyone having a nice day.

I have find lot of crash files in /var directory 
But i don't known which files need to delete and which files need to keep.

some of my files are 

/var/adm/crash/crash.8/image.8.1

/var/adm/crash/crash.8/vmunix

/var/adm/crash/crash.0/image.7.4

I am all ears to any kind of suggestions
Thank your help in advance.
Regards 
Jason D 

3 REPLIES 3
Steven Schweda
Honored Contributor

Re: House keeping the var directory

> I have find lot of crash files in /var directory
> But i don't known which files need to delete and which files need to
> keep.

   What are the dates on these crash-dump files?  Do you intend ever to
analyze them?  If not, then why keep any of them?

> I am all ears to any kind of suggestions

   What did you find when you did a Web or Forum search for terms like?:
      hp-ux /var/adm/crash

   One result from my quick search:

      https://community.hpe.com/t5/x/x/td-p/5360993

pooderbill
Valued Contributor

Re: House keeping the var directory

The contents of the /var/adm/crash directory is only needed if you need an answer as to the reason for the crash(es). You'll need a software support contract for HP-UX in order to submit the crash dump for analysis. Otherwise, the entire contents of /var/adm/crash can be removed.

Bill Hassell
Honored Contributor

Re: House keeping the var directory

And for everyone, add these scripts to your sysadmin tools:

#!/usr/bin/sh

#
#    #####   #    #   ####
#    #    #  #    #  #
#    #    #  #    #   ####
#    #    #  #    #       #
#    #    #  #    #  #    #
#    #####    ####    ####
#

# blh 2010 Aug Modified to show KB, MB, GB
#              Modified to show any errors
# Bill Hassell Feb 1997
#  modified to show one screen with headers
#  redirect errors and display at bottom
#  dropped pre-10.00 512 byte msg and /bin stuff

# Simple script to track down directory utilization
#   on a single volume and sort largest first
#
# USAGE:
#   dus <starting-point-for-du>

set -u
MYNAME=${0##*/}
MYTEMPDIR=/var/tmp/$MYNAME.$$
export PATH=/usr/bin

rm -rf $MYTEMPDIR
mkdir $MYTEMPDIR
trap "/usr/bin/rm -rf $MYTEMPDIR;exit" 0 1 2 3 11 12 15

# Seleect 1000 or 1024 for K units

KB=1000
while getopts ":k" OPTCHAR
do
   case $OPTCHAR in
        k) KB=1024              # show in 1024 K-units
           ;;
        *) eval "ERROPT=\$$(($OPTIND-1))"
           Usage "Invalid option(s): $ERROPT, ignored"
           ;;
   esac
done
shift $(($OPTIND -1))

# Setup test and divisor values

let MB=$KB*$KB
let GB=$KB*$KB*$KB
typeset -R6 VARSIZE

# run du and redirect errors into a file

echo "Dir-Size   Directory name"
du -kx ${@+"$@"} 2> $MYTEMPDIR/errors \
   | sort -n -r \
   | head -$((LINES-4)) \
   | while read DIRSIZE DIRNAME
do
   DIGITS=${#DIRSIZE}


   if [[ $DIGITS -gt 9 ]]
   then
      UNITS=TB
      RSIZE=$(echo "scale=1 \n $DIRSIZE/$GB" | bc)
   elif [[ $DIGITS -gt 6 ]]
   then
      UNITS=GB
      RSIZE=$(echo "scale=1 \n $DIRSIZE/$MB" | bc)
   elif [[ $DIGITS -gt 3 ]]
   then
      UNITS=MB
      RSIZE=$(echo "scale=1 \n $DIRSIZE/$KB" | bc)
   fi

   if [[ $DIGITS -le 3 ]]
   then
      UNITS=KB
      VARSIZE=$(printf "%6i" $DIRSIZE)
   else
      VARSIZE=$(printf "%4.1f" $RSIZE)
   fi

   echo "$VARSIZE $UNITS  $DIRNAME"
done

if [[ -s $MYTEMPDIR/errors ]]
then
    echo "--permission errors accessing some directories--"
    cat $MYTEMPDIR/errors | while read TEXT
    do
       echo "  $TEXT"
    done
    echo
fi

dus is a better du command. It sorts the directories by size, like this:

# dus /var
Dir-Size   Directory name
  10.2 GB  /var
   2.9 GB  /var/adm
   2.8 GB  /var/opt
   2.4 GB  /var/adm/sw
   2.4 GB  /var/tmp
   1.9 GB  /var/adm/sw/save
   1.5 GB  /var/opt/omni
   1.2 GB  /var/opt/omni/server
   1.1 GB  /var/tmp/pw
   1.1 GB  /var/opt/omni/server/db80
   1.1 GB  /var/testing
   1.1 GB  /var/opt/omni/server/db80/pg
   1.0 GB  /var/opt/omni/server/db80/pg/pg_xlog_archive.arch


When managing filesystems space, DON'T LOOK FOR BIG FILES.
Instead, look for big directories!
You may have a /var/tmp/testing directory with a bunch of 1 MB files (like thousands).
No big files but the junk directory occupies gigabytes.
Run it on any mountpoint with high usage (like 90% or more)

Once you find a suspicious directory, use this to sort the contents by size:

#!/usr/bin/sh
# POSIX-sh and ksh compatible

###################################
#
#     #       #        #####
#     #       #       #     #
#     #       #       #
#     #       #        #####
#     #       #             #
#     #       #       #     #
#     ####### #######  #####
#
###################################

# Revision history
# Jun  2 2023 blh Changed pager to more -## and added header line
# Oct  3 2022 blh Changed suffix from lower b to B for bytes
# May 14 2014 blh Added -r and -l options
# Dec 11 2013 blh Added -q option
#                 Drop -F option for a clean filename
# Jun 07 2013 blh Fixup to handle ll for multiple directories
# Jun 07 2013 blh Major rewrite to handle Gb and Tb without overflow
# Apr 07 2013 blh Added -t and PAGER choice
#                 Added tag line for magnitude
# Nov 03 2012 blh Original version
#

# Script to list largest files first with KB MB GB adjustments
# Output matches field widths for ll but one additional
#    field is added for units of measure (B KB MB GB)
#   -k = use 1000 rather than 1024 for kilo

# CUSTOMIZATION:
#
# Set PAGER=<favorite pager such as more or less, etc>
#

USAGETXT="
  Usage: $MYNAME [-kq] [-l <len>] [ optional path(s) ]
    where -k = use 1000 instead of 1024 for kilo
          -l <len> = shows <len> lines (no PAGER)
          -q = quiet (no note at the end)
"

set -u
export PATH=/usr/bin
MYNAME=${0##*/}

TRACEME=${TRACEME:-false}               # TRACEME non-null = trace on
[ $TRACEME != false ]  && set -x && PS4='[$LINENO]: '

typeset -L10 PERM
typeset -R3  LINKS
typeset -L10 UID UIDBLANK
typeset -L8  GID
typeset -R6  VARSIZE
UIDBLANK=" "



# F U N C T I O N S
###################

###########
#  Usage  #
###########

function Usage
{
 # Minimum Usage function
 # Requires $USAGETXT to be assigned externally.
 #   Typically, this is done at the start of a script
 #   to act as both documentation and a Usage message

  TRACEME=${TRACEME:-false}      # TRACEME non-null = trace on
  [ $TRACEME != false ]  && set -x && PS4='[$LINENO]: '
  MYNAME=${MYNAME:-${0##*/}}

# If supplied, show an error message
  if [ $# -gt 0 ]
  then
     ERRMSG="$*"
     echo "\n$ERRMSG"
     WIDTH=${#ERRMSG}
     eval typeset -Z$WIDTH BAR=0
     echo "$BAR" | tr "0" "="
  fi

# Show the usage message - handle missing USAGETXT

  USAGETXT=${USAGETXT:-NotSet}
  [[ "$USAGETXT" = "NotSet" || "$USAGETXT" = "" ]] &&
     echo "\n$MYNAME: USAGETXT is null or not assigned" ||
     echo "$USAGETXT"
  exit 1
}


##################
#  Main Program  #
##################

KB=1024
QUIET=false
FIXEDLEN=0

while getopts ":qkl:" OPTCHAR
do
   case $OPTCHAR in
        k) KB=1000
           ;;
        l) FIXEDLEN="$OPTARG"
           ;;
        q) QUIET=true
           ;;
        *) eval "ERROPT=\$$(($OPTIND-1))"
           Usage "Invalid option(s): $ERROPT"
           ;;
   esac
done
shift $(($OPTIND -1))

# Setup test and divisor values

let KB1=$KB-1
let MB=$KB*$KB
let MB1=$KB*$KB-1
let GB=$KB*$KB*$KB
let GB1=$KB*$KB*$KB-1

# The incantation ${@+"$@"} ensures that all possible command line
# parameters will be represented including null and space/tab strings.
# This makes the script work exactly like ll except for the units of
# measure.

echo "--------- Largest files first ------------"

ls -la ${@+"$@"} \
   | sort -rnk5 \
   | while read PERM LINKS UID GID SIZE REST
     do
       [ "$UID" = "$UIDBLANK" ] && continue     # break out - ll returned subdirs
# find overall magnitude
       if [ "$PERM" != "total     " ]
       then
         SIZEDIGITS=${#SIZE}
         if [ $SIZEDIGITS -ge 13 ]                      # terabytes
         then
           [ $KB -eq 1000 ] && UNITS=Tib || UNITS="TB"
           RSIZE=$(echo "scale=1 \n $SIZE/$GB/$KB" | bc)
         elif [ $SIZEDIGITS -ge 10 ]                    # gigabytes
         then
           [ $KB -eq 1000 ] && UNITS="GiB" || UNITS="GB"
           RSIZE=$(echo "scale=1 \n $SIZE/$GB" | bc)
         elif [ $SIZEDIGITS -ge 7 ]                     # megabytes
         then
           [ $KB -eq 1000 ] && UNITS="MiB" || UNITS="MB"
           RSIZE=$(echo "scale=1 \n $SIZE/$MB" | bc)
         elif [ $SIZEDIGITS -ge 4 ]                     # kilobytes
         then
           [ $KB -eq 1000 ] && UNITS="KiB" || UNITS="KB"
           RSIZE=$(echo "scale=1 \n $SIZE/$KB" | bc)
         fi
         if [ $SIZEDIGITS -le 3 ]                       # bytes
         then
           [ $KB -eq 1000 ] && UNITS="B  " || UNITS="B "
           RSIZE=$SIZE
           VARSIZE=$(printf "%6i" $SIZE)
         else
           VARSIZE=$(printf "%4.1f" $RSIZE)
         fi
         echo "$PERM $LINKS $UID $GID $VARSIZE $UNITS $REST"
       fi
     done | more -$(($LINES-2))

[[ "$QUIET" = false ]] &&
   [[ KB -eq 1000 ]] &&
      echo "Note: KiB = 1024 bytes, M=K*K G=M*M" ||
      echo "Note: KB = 1000 bytes, M=K*K G=M*M"

 

The lls script sorts the directory by size:

 # lls /var/tmp
--------- Largest files first ------------
-rwxr-xr-x   1 root       sys        23.1 MB May 14  2018 ixNet-SNMP_A.19.00-5.6.1.1.001_HP-UX_B.11.31_IA_PA.depot
-rw-r--r--   1 root       sys        16.1 MB Apr  8 08:20 swlist.out
-rw-r--r--   1 root       sys       504.8 KB May 21  2023 atl6-crashcollector-2023-0521.2303.tar.gz
-rw-------   1 root       sys       280.0 KB Jul 10  2014 scrub-2.5.2-ia64-11.31.depot
-rw-r--r--   1 root       sys       100.0 KB Jan 23  2023 atl1.srp.conf
-rw-r--r--   1 root       sys        92.5 KB May 21  2023 ems_index_file.data
-rw-r--r--   1 root       sys        83.4 KB May 21  2023 xml_index_file.data
-rw-r--r--   1 sfmdb      users      80.0 KB Jul 15  2012 gda001286
-rw-r--r--   1 root       sys        80.0 KB Apr  7  2014 AAA008345
-rw-------   1 root       sys        80.0 KB Jan  4 11:30 RxCAA025001
-rw-------   1 root       sys        79.4 KB Jul  7  2017 nettltr.TRC000
-rwxr-xr-x   1 root       sys        69.8 KB May 11  2016 nc
-rw-------   1 root       sys        66.9 KB Oct  1  2017 raw0.TRC000
-rw-r--r--   1 root       sys        62.9 KB May 13  2014 passwd.out
-rw-r--r--   1 root       sys        56.0 KB Aug 10  2012 fptouKAA004462.0
-rw-------   1 root       sys        48.0 KB May  7 20:24 ExDAA016305
-rw-r--r--   1 root       sys        42.4 KB Jan 26 00:34 swagent.log





Bill Hassell, sysadmin