#!/bin/bash
RESTART="........" #里面写相应服务代码
START="......."
STOP=".........."
case "$1" in
restart)
$RESTART
echo "......"
;;
start)
$START
echo "......"
;;
STOP)
$STOP
echo "......"
;;
*)
echo "Usage: $0 { restart ¦ start ¦ stop}"
exit 1
esac
exit 1
脚本写完要修改一下权限 chmod u+x test.sh
首先,但是发现了一个问题:FC12在登陆后才完成系统启动,
#!/bin/sh
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
else
. /lib/lsb/init-functions
fi
MOD=/a.ko
start()
{
echo -n $"insert a kernel module: "
/sbin/insmod $MOD
echo
}
stop()
{
echo -n $"remove a kernel module: "
/sbin/rmmod a -f
echo
}
[ -f $MOD ] || exit 0
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo $"Usage: $0 { start|stop|restart|reload}"
update-rc.d命令,然后执行如下指令:
update-rc.d a start 90 2 3 4 5 . stop 90 0 1 6 .
其中a就是你的脚本,
这个脚本其实很简单,bin在linux里表示可以执行的程序。然后bash在用户起始目录下按顺序查找三个特殊文件中的一个:/.bash_profile、也就是说,可以在开机启动后直接进入X-Window。按先后顺序,也就是rc5.d,第二行就是要运行的命令。
例:
在 /etc/init.d 中建立一个叫作 zope 的 script , 然后
update-rc.d zope defaults
就会产生以下链結::
Adding system startup for /etc/init.d/zope ...
/etc/rc0.d/K20zope -> ../init.d/zope
/etc/rc1.d/K20zope -> ../init.d/zope
/etc/rc6.d/K20zope -> ../init.d/zope
/etc/rc2.d/S20zope -> ../init.d/zope
/etc/rc3.d/S20zope -> ../init.d/zope
/etc/rc4.d/S20zope -> ../init.d/zope
/etc/rc5.d/S20zope -> ../init.d/zope
其他进阶使用方式请 man update-rc.d
关键词:linux






$ at 12:00
at>mailto Roger -s ″Have a lunch″ < plan.txt
at>Ctr-D
Job 1 at 2000-11-09 12:00
2000-11-09 12:00时候自动发一标题为"Have a lunch",6这两个运行级别中, 使用chkconfig命令可以查看在不同启动级别下课自动启动的服务(或是程序), linux添加开机启动项