服务不支持chkconfig的

编程入门 行业动态 更新时间:2024-10-28 08:29:03
本文介绍了服务不支持chkconfig的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好,程序员。我有个问题。请帮忙。我创建一个服务,是正装的Linux时必须自动加载。所以,我复制脚本到该目录/etc/rc.d/init.d中或/etc/init.d/的。但是,当我preforming命令

Good day,programmers. I have a problem. Please help. I am creating a service, which must load automatically when Linux is being loaded. So,I copied the script into the directory /etc/rc.d/init.d or /etc/init.d/. But when I am preforming the command

chkconfig --add listOfProcesses

时发生错误:

service listOfProcesses doesn't support chkconfig

下面是脚本的内容。我发现在谷歌的第一个版本,并用它作为一个模式。

Here is the content of the script. I have found the first version in the Google and have used it as a pattern.

#!/bin/bash # listOfProcesses Start the process which will show the list of processes # chkconfig: 345 110 02 # description: This process shows current time and the list of processes # processname: listOfProcesses ### BEGIN INIT INFO # Provides: # Required-Start: # Required-Stop: # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # Short-Description: shows current time and the list of processes # Description: This process shows current time and the list of processes ### END INIT INFO # Source function library. KIND="listOfProcesses" start() { echo -n $"Starting $KIND services: " daemon /home/myscript echo } stop() { echo -n $"Shutting down $KIND services: " killproc /home/myscript echo } restart() { echo -n $"Restarting $KIND services: " killproc /home/myscript daemon /home/myscript echo } case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac exit $? exit 0;

第二个版本是从cron的脚本制作。我发现的cron脚本,它复制,并改变它,所以我用它作为图案。

The second version was made from the cron script. I found the cron script,copied it, and changed it, so I used it as the pattern.

#!/bin/sh # # crond Start/Stop the cron clock daemon. # # chkconfig: 2345 90 60 # description: cron is a standard UNIX program that runs user-specified \ # programs at periodic scheduled times. vixie cron adds a \ # number of features to the basic UNIX cron, including better \ # security and more powerful configuration options. ### BEGIN INIT INFO # Provides: crond crontab # Required-Start: $local_fs $syslog # Required-Stop: $local_fs $syslog # Default-Start: 2345 # Default-Stop: 90 # Short-Description: run cron daemon # Description: cron is a standard UNIX program that runs user-specified # programs at periodic scheduled times. vixie cron adds a # number of features to the basic UNIX cron, including better # security and more powerful configuration options. ### END INIT INFO rights=whoami; root=root; [ -f "$rights"=="$root" ] || { echo "this programme requires root rights"; exit 1; } # Source function library. . /etc/rc.d/init.d/functions start() { echo -n $"Starting $KIND services: "; daemon showListOfProcesses; } stop() { echo -n $"Shutting down $KIND services: "; killproc showListOfProcesses; } restart() { stop start } reload() { restart; } force_reload() { # new configuration takes effect after restart restart } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; force-reload) force_reload ;; *) echo $"Usage: $0 {start|stop|restart|reload|force-reload}" exit 2 esac exit $? # Show the list of processes function showListOfProcesses { top > /dev/tty2; }

但情况并没有改变。问题是什么?什么是错误的脚本?

But the situation hadn't changed. What is the problem? What is wrong in the script?

推荐答案

看看所有的的chkconfig 可以打开或脚本关闭中的 / etc / rc中.D / init.d中的,你会发现,排在前几位的意见是非常重要的。见如何,要管理的chkconfig和服务服务

Look at all the scripts that chkconfig can turn on or off in /etc/rc.d/init.d, you'll notice that the top few comments are very important. See How-To manage services with chkconfig and service

#!/bin/sh # # crond Start/Stop the cron clock daemon. # # chkconfig: 2345 90 60 # description: cron is a standard UNIX program that runs user-specified \ # programs at periodic scheduled times. vixie cron adds a \ # number of features to the basic UNIX cron, including better \ # security and more powerful configuration options.

您有一个名为脚本 listofprocesses 但的chkconfig 这个脚本看起来像 crond的由于3号线,因此它没有找到一个名为任何脚本 listofprocesses

You have a script called listofprocesses but to chkconfig this script looks like crond due to the 3rd line and thus it does not find any script called listofprocesses

您还可以肯定要换的chkconfig:2345 90 60 。它说其中的运行级别应该是对(在本例中2,3,4和5),它的启动顺序是(90)和它的击杀顺序是(60)。

You'll also most certainly want to change chkconfig: 2345 90 60. Which says which run levels it should be on (in this case 2, 3, 4 and 5), what it's start order is (90) and what its kill order is (60).

您可以检查该服务已正确设置了的chkconfig --list listofprocesses 。

You can check the service is correctly set up with chkconfig --list listofprocesses.

更多推荐

服务不支持chkconfig的

本文发布于:2023-10-30 12:20:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542828.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   chkconfig

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!