免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 867 | 回复: 0
打印 上一主题 下一主题

UNIX -- trick and experience 20090423 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-23 21:58 |只看该作者 |倒序浏览
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
#
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

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/94480/showart_1908552.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP