易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux环境下判断服务器是否正常关机

Linux环境下判断服务器是否正常关机
2009-05-17  来自:ZDNet     收藏
系统启动的时候生成一个文件,正常关机的时候则删除这个文件,则可以根据系统开机时有没有那个文件来判断是不是非正常关机。
系统启动的时候生成一个文件,正常关机的时候则删除这个文件,则可以根据系统开机时有没有那个文件来判断是不是非正常关机。
步骤:
在/etc/rc.d/init.d/下编程脚本。
判断是否正常关机,和生成文件的脚本:touch-file.sh
#!/bin/sh file=/tmp/check if [ -e $ ];then echo "this is not normal shutdown" >>/var/log/checkmessage else echo "this is normal shutdown and touch file" >>/var/log/checkmessage touch $ fi
正常关机删除文件的脚本:rm-file.sh
#!/bin/sh file=/tmp/check echo "this is normal shutdown and rm file" >>/var/log/checkmessage rm -rf $
让脚本自动执行。
ln -s /etc/rc.d/rc0.d/K01rm-file /etc/rc.d/init.d/rm-file.sh
注意:
#ll /etc/rc.d/rc0.d/
软连接两边的名字不哪呢个相同,后一个可以用绝对路径或是相对路径,千万保证两边的名字不一样。
ln -s /etc/rc.d/rc6.d/K01rm-file /etc/rc.d/init.d/rm-file.sh ln -s /etc/rc.d/rc3.d/S01touch-file /etc/rc.d/init.d/touch-file.sh
我的系统没用到x-window,所以没有level5,也就是不用在/etc/rc.d/rc5.d/下放脚本。
特别注意:
K开头的代表系统关闭的时候执行,S开头的代表开机的时候执行。注意服务器脚本编写的规范,因为有K开通的软链接并不一定会在关机的时候自动去执行,这是为什么呢?执行K脚本的时候会查询/var/lock/subsys/下是否有与K开头脚本同名的空文件名,如果没有就不去执行,所以要按照服务器脚本编写的规范,启动的时候要在/var/lock/subsys/先touch一个与K01后面同名的空文件:
#/var/lock/subsys #touch fm-file


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

实战Linux Bluetooth编程(六) L2CAP编程实例

例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
 如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......

Linux netfilter源码分析(4)


四、nf_hook_ops 钩子的注册
在filter表的初始化函数static int __init init(void)中除了有一个nf_register_hook函数注册一个tables外,还由nf_register_hook函数注册了3个hook
 
4.1        nf_hook_ops数据结构 netfilter.h
struct nf_hook_ops
{
      ......

Linux netfilter源码分析(7)

转贴自:http://alexanderlaw.blog.hexun.com/8968960_d.html
七、 target 匹配
7.1 ipt_target和ipt_entry_target结构      ip_tables.h
ipt_target和ipt_match结构类似:
struct ipt_target
{
      struct list_head list;
 
    & ......

Linux 环境进程间通信(六)


Linux 环境进程间通信(六)
套接口
文档选项
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td><td width="16"><img alt="" width=" ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号