导航

centos开机启动脚本

Posted on 2013-06-12 22:12  疯狂原始人  阅读(238)  评论(0)    收藏  举报

通过启动脚本来创建一个服务,使用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为要执行脚本