LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 163|回复: 0

SysV脚本的特性

[复制链接]
发表于 2023-12-19 16:29:28 | 显示全部楼层 |阅读模式

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


您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表