UNIX shell -- trick and experience (20090423)

本文提供了一系列UNIX系统管理技巧与经验,包括自动化日常任务、备份重要文件、常规工作流程优化、禁用不必要的守护进程、确保守护进程运行等。详细介绍了如何通过脚本设置时区、使用fuser替代ps、快速建立磁盘交换分区、使用nohup保持进程运行、重定向输出到NULL设备、限制用户登录等实用技巧。
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) |
给主人留下些什么吧!~~
评论热议
考虑柔性负荷的综合能源系统低碳经济优化调度【考虑碳交易机制】(Matlab代码实现)内容概要:本文围绕“考虑柔性负荷的综合能源系统低碳经济优化调度”展开,重点研究在碳交易机制下如何实现综合能源系统的低碳化与经济性协同优化。通过构建包含风电、光伏、储能、柔性负荷等多种能源形式的系统模型,结合碳交易成本与能源调度成本,提出优化调度策略,以降低碳排放并提升系统运行经济性。文中采用Matlab进行仿真代码实现,验证了所提模型在平衡能源供需、平抑可再生能源波动、引导柔性负荷参与调度等方面的有效性,为低碳能源系统的设计与运行提供了技术支撑。; 适合人群:具备一定电力系统、能源系统背景,熟悉Matlab编程,从事能源优化、低碳调度、综合能源系统等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①研究碳交易机制对综合能源系统调度决策的影响;②实现柔性负荷在削峰填谷、促进可再生能源消纳中的作用;③掌握基于Matlab的能源系统建模与优化求解方法;④为实际综合能源项目提供低碳经济调度方案参考。; 阅读建议:建议读者结合Matlab代码深入理解模型构建与求解过程,重点关注目标函数设计、约束条件设置及碳交易成本的量化方式,可进一步扩展至多能互补、需求响应等场景进行二次开发与仿真验证。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值