SysV脚本的特性
SysV风格的服务启动脚本有以下几个特性:
一般都放在/etc/rc.d/init.d目录下。
这类脚本要求能接受start、stop、restart、status等参数来管理服务进程。
基本上都会加载/etc/rc.d/init.d/functions文件,因为该文件中定义了几个对进程管理非常有用的函数。
基本上都会加载/etc/sysconfig目录下的同名文件。此目录下的服务同名文件一般都是为服务管理脚本提供选项参数的。例如/etc/sysconfig/httpd。
在脚本的顶端,需要加上# chkconfig和# description两行。chkconfig行定义的是该脚本被chkconfig工具管理时的主要依据,包括开机和关机时的启动、关闭顺序,以及运行在哪些运行级别。description是该脚本的描述性语句。虽然这两行以#开头,但必不可少。
例如,/etc/init.d/httpd脚本的前面几行内容如下:
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd/httpd.pid
#
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then # 判断后再加载
. /etc/sysconfig/httpd
fi
|