您的位置:首页 > Web前端

Fedora如何实现自动运行

2015-10-21 16:04 253 查看
1.在/etc/init.d/中创建脚本,运用如下的格式

#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
# code to start app comes here
# example: daemon program_name &
}

stop() {
# code to stop app comes here
# example: killproc program_name
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
# code to check status of app comes here
# example: status program_name
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac

exit 0

可以参考/etc/init.d/中其他的脚本实现如上格式的脚本,创建完之后可以运行script,/etc/init.d/myscript start 或者chkconfig myscript start.

2、使能脚本实现脚本自动运行

$ chkconfig --add myscript
$ chkconfig --level 2345 myscript on

3、检查脚本是否配置成功

$ chkconfig --list | grep myscript
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: