#!/usr/local/bin/perl # move_sa # Perl script to monitor and correct /var full situations # by moving sa data files to another partition and symbolic linking to them # Written 4/1/99 by Robert G. Ferrell $source_dir = qq(/var/adm/sa); # Insert your source directory $targ_dir = qq(/u08/var/adm); # Insert your target directory $part = qq(/var); # The partition in question chomp($today = qx(date '+%d')); # Don't move today's file sub check_dirs { unless ((-d $source_dir) && (-d $targ_dir)) { print "One of your directories is bogus\n"; exit(); } } opendir(DIR, $source_dir) || die "couldn't read $source_dir??!!\n"; @files = readdir(DIR); closedir(DIR); foreach $file (@files) { $file_path = qq($source_dir/$file); unless ((-l $file_path) || ($file =~ qq(sa$today)) || ($file =~ /sar/) || ($file =~ /^\./)) { qx(mv $file_path $targ_dir); qx(ln -s $targ_dir/$file $file_path); } } $list = qx(ls -la $source_dir); $confirm = qx(df -k $part); # See what effect you had on the full partition print <<"End_of_print"; ******************************************************* New Contents of $targ_dir: $list ******************************************************* New status of /var partition: $confirm End_of_print