UNIX shell -- trick and experience (20090423)

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
<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) |
给主人留下些什么吧!~~
评论热议
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值