通过启动脚本来创建一个服务,使用chkconfig来指定启动服务级别、
chkconfig 命令用来更新和查询不同运行级上的系统服务。
语法为:
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name
chkconfig [--level levels] name
在/etc/init.d/文件夹下新建服务
[root@atl ~]# vim /etc/init.d/vagexrun
[root@atl ~]# chmod +x /etc/init.d/vagexrun
[root@atl ~]# chkconfig --add vagexrun
#! /bin/sh #add for chkconfig #chkconfig: 2345 70 30 #description: the description of the sh #processname: vagexrun export USER="root" export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11" su - $USER -c"/root/vagex.sh" esac exit 0
/root/vagex.sh为要执行脚本
浙公网安备 33010602011771号