UNIX -- trick and experience
author: kirk waingrow
just a copy,please refer freely
chapter 1 system management
overview:
daily jobs automation
system modification
section 1 collect system messages
# hostname
# grep 'hostname' /etc/hosts | awk '{print $3}'
# hostid
# uname -a
# dmesg
# df
section 2 backup important files
kernel files:/kernel;/unix or /vmunix
password file:/etc/passwd
group files:/etc/group
host table:/etc/hosts
filesystem table:/etc/fstab or /etc/vfstab
sendmail config file:/usr/lib/sendmail.cf or /usr/lib/sendmail.fc or /usr/lib/sendmail.mc
inetd config file:/etc/inetd.conf
TTY setting files:/etc/inittab or /etc/ttytab or /etc/ttys
start up scripts:/etc/init.d or /etc/rc#.d
section 3 routine work
TZ={GMT|PST|EDT|...}-24 date + %d
##/bin/bash
FILE = 'runme'
if test 'TZ=PST-24 date + %d' = 1 ;then
$FILE
fi
#!/usr/bin/perl
use POSIX;
@THE_DATE=localtime(time);
++ $ THE_DATE[3];
if((localtime(POXIX::mktime(@THE_DATE)))[3]==1){
exit 0;
}
exit 1;
addition:cron/crontab can not judge whether today is the last day of the current month
reference:localtime tzset tzfile crontab
section 4 disable unnecessary daemon processes
modify:/etc/inetd.conf file with rc file
after modification type command:kill -HUP inetd_PID and check the logfile:/var/adm/messages or /var/adm/SYYLOG
after modify the rc file,you must reboot immediately
addition:inetd inetd.conf rc
section 5 assuring daemon processes are running
addition:cron crontab ps test
section 6 use fuser instead of ps
comparing the commands to get PID ,fuser is more reliable and quick than ps
# fuser /bin/csh
# fuser -k /bin/csh
addition:fuser ps kill
section 7 building disk swap partition quickly
section 8 using nohup command to keep processes running
section 9 redirect output to NULL device
purge useless files
section 10 stoping users login
modify /etc/passwd
modify /etc/inetd.conf
close network interface
close the access of remote shell and telnet
it needs /etc/nologin
for example:add the section as below
the system is down right now fo rroutin e maintenance and should be back online by 23:00 . please
check back at this time . thank you for your understanding . the unix admins .
close the access of remote ftp
/etc/users
# cut -d":" -f1 /etc/passwd > /etc/users
# ypcat passwd | cut -d":' -f1 > /etc/users
addition:inetd nologin users ypcat
section 11 quickly rewinding of tape
# mt -f /dev/rmt/0cbn rewind
# < /dev/rmt/0cbn
# < $DLT ; tar cvf $DLT /usr/spool/mail;< $DLT
addition:mt
section 12 generating a set of continuous digits
#!/bin/sh
# the script name is count
lo=$1;hi=$2
while [ $lo -lt $hi ]
do
echo -n $lo" "
lo='expr $lo + 1'
done
#!/bin/sh
string="the quick brown fox jumped readlly high"
for i in 'echo "5 6 7 8 9"'
do
echo $string | cut -c $i
done
#!/bin/sh
string ="the quick brown fox jumped readlly high"
for i in 'count 5 20' ### count is the script name above
do
echo $string | cut -c $i
done
阅读(614) | 评论(0) | 转发(0) |