linux服务脚本/etc/init.d/xxxx

来源:互联网 发布:机器人 编程 编辑:程序博客网 时间:2024/06/02 03:56

服务脚本的写法:

#!/bin/bash### BEGIN INIT INFO# Provides:          MyServer# RequiRED-Start:    $all# RequiRED-Stop:     $all# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: my service.# Description:       my service.### END INIT INFORED="\\e[31m"GREEN="\\e[32m"YELLOW="\\e[33m"BLACK="\\e[0m"POS="\\e[60G"ok_msg(){    echo -e "${1}${POS}${BLACK}[${GREEN}  OK  ${BLACK}]"}failed_msg(){    echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]"}start() {    failed_msg "Scheduler started, should not start it again."}stop() {    ok_msg "Stopping scheduler..."}status() {    echo "status ok!"}case "$1" in    start)        start        ;;    stop)        stop        ;;    restart)        stop        start        ;;    status)        status        ;;    *)        echo "Usage: $0 {start|stop|status|restart}"        exit 1        ;;esacexit $RETVAL