linux开机自动启动一些服务


linux 开机自动启动一些服务,有很多方法,下面介绍两种1 要开机 运行只需将它加入到 rc local ,一般为 etc rc d rc local 在其中加入 linux 开机自动启动一些服务,有很多方法,下面介绍两种

1.要开机 运行只需将它加入到 rc.local ,一般为/etc/rc.d/rc.local 在其中加入以下行:
例子是开机后自动创建一个bbb.txt

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
sh /test/init.sh
下面是/test/init.sh中的内容

#! /bin/bash
touch /test/bbb.txt

2.第二种是做成一个服务
linux的服务放置在/etc/init.d目录下,新建一个initb服务
1. /etc/init.d/initb 的内容如下
#!/bin/bash
# chkconfig: 2345 10 90
# description: myservice ....
touch /test/initb.txt

3、运行chmod +x /etc/rc.d/init.d/initb,使之可直接执行

4、运行chkconfig --add initb,把该服务添加到配置当中

5、运行chkconfig --list initb,可以查看该服务进程的状态
6.重启后,在/test目录下就会出现initb.txt

相关内容

    暂无相关文章