加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Linux守护进程启动

发布时间:2020-12-14 00:52:21 所属栏目:Linux 来源:网络整理
导读:我在 linux上编写了一个服务(Redhat Server Edition 5.1).这是由shell scritpt启动的, 如果我启动我的应用程序,我手动启动我的服务,现在我想在启动时启动我的服务,通过我的服务在我的守护程序的init.d文件夹不在启动时调用,任何有想法如何开始 Linux上启动时
我在 linux上编写了一个服务(Redhat Server Edition 5.1).这是由shell scritpt启动的,
如果我启动我的应用程序,我手动启动我的服务,现在我想在启动时启动我的服务,通过我的服务在我的守护程序的init.d文件夹不在启动时调用,任何有想法如何开始 Linux上启动时的守护进程?

这个我的样本但是没有用

#!/bin/sh
#
# myservice     This shell script takes care of starting and stopping
#               the <myservice>
#

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


# Do preliminary checks here,if any
#### START of preliminary checks #########


##### END of preliminary checks #######


# Handle manual control parameters like start,stop,status,restart,etc.

case "$1" in
  start)
    # Start daemons.

    echo -n $"Starting <myservice> daemon: "
    echo
    daemon <myservice>
    echo
    ;;

  stop)
    # Stop daemons.
    echo -n $"Shutting down <myservice>: "
    killproc <myservice>
    echo

    # Do clean-up works here like removing pid files from /var/run,etc.
    ;;
  status)
    status <myservice>

    ;;
  restart)
    $0 stop
    $0 start
    ;;

  *)
    echo $"Usage: $0 {start|stop|status|restart}"
    exit 1
esac

exit 0

解决方法

在您的脚本中添加2条评论:

# chkconfig: - 90 10
# description: description of your service

以root身份运行:

chkconfig --add my_service

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读