UNIX -- trick and experience
author: kirk waingrow
just a copy,please refer freely
chapter 1 system management
overview:
daily jobs automation
system modification
daily jobs automation
system modification
section 1 collect system messages
# hostname
# grep 'hostname' /etc/hosts | awk '{print $3}'
# hostid
# uname -a
# dmesg
# df
# 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
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
##/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;
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 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
# 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
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
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
# < /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
# the script name is count
lo=$1;hi=$2
while [ $lo -lt $hi ]
do
echo -n $lo" "
lo='expr $lo + 1'
done
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
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
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
<script>window._bd_share_config={"common":{"bdsnskey":{},"bdtext":"","bdmini":"2","bdminilist":false,"bdpic":"","bdstyle":"0","bdsize":"16"},"share":{}};with(document)0[(getelementsbytagname('head')[0]||body).appendchild(createelement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new date()/36e5)];</script>
阅读(277) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
评论热议
本文提供了一系列UNIX系统管理技巧与经验,包括自动化日常任务、备份重要文件、常规工作流程优化、禁用不必要的守护进程、确保守护进程运行等。详细介绍了如何通过脚本设置时区、使用fuser替代ps、快速建立磁盘交换分区、使用nohup保持进程运行、重定向输出到NULL设备、限制用户登录等实用技巧。
335

被折叠的 条评论
为什么被折叠?



