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

shell – SHOUTcast守护程序脚本无法正常运行

发布时间:2020-12-15 22:57:14 所属栏目:安全 来源:网络整理
导读:我在Ubuntu上运行了一个SHOUTcast服务器.服务器进程运行良好,但我似乎无法使守护进程脚本正常运行.经过几个教程,我发现我想出了这个: #!/bin/shCONFIG="/home/apps/shout32/sc_plex.conf"DAEMON="/home/apps/shout32/sc_serv"case "$1" in start) echo "Sta
我在Ubuntu上运行了一个SHOUTcast服务器.服务器进程运行良好,但我似乎无法使守护进程脚本正常运行.经过几个教程,我发现我想出了这个:

#!/bin/sh

CONFIG="/home/apps/shout32/sc_plex.conf"
DAEMON="/home/apps/shout32/sc_serv"

case "$1" in
    start)
        echo "Starting SC..."
        $DAEMON $CONFIG > /dev/null 2>&1 &
        ;;
    stop)
        echo "Stopping SC..."
        kill -9 `ps -C sc_serv -o pid --no-headers`
        ;;
    restart)
        echo "Rebooting SC..."
        kill -9 `ps -C sc_serv -o pid --no-headers`
        $DAEMON $CONFIG > /dev/null 2>&1 &
        ;;
    *)
        echo "usage: service sc32d {start | stop | restart}"
        exit 1
        ;;
esac

然而,这不起作用.我不知道这意味着什么,所以我开始逐行分解.如果我删除/ dev / null的东西 – 正如我现在所理解的那样让程序在后台运行’无声’ – 我收到此消息,程序关闭:

root@streams3:/etc/init.d# service sc32d start
Starting SC...
root@streams3:/etc/init.d# 2013-05-21 14:41:50  E       msg:<***>       logger could not open file logs/sc_serv.log
2013-05-21 14:41:50     I       msg:<***>       Logger shutdown

root@streams3:/etc/init.d#
root@streams3:/etc/init.d# ps -C sc_serv
  PID TTY          TIME CMD
root@streams3:/etc/init.d#

我还在研究/ dev / null究竟做了什么以及为什么这样做,所以我想用手工运行所有/ dev / null的东西,我做了,这就是我得到某种错误代码的地方:

root@streams3:/etc/init.d# /home/apps/shout32/sc_serv /home/apps/shout32/sc_plex.conf > /dev/null 2>&1 &
[2] 2261
root@streams3:/etc/init.d#
[2]-  Exit 255                /home/apps/shout32/sc_serv /home/apps/shout32/sc_plex.conf > /dev/null 2>&1
root@streams3:/etc/init.d# ps -C sc_serv
  PID TTY          TIME CMD

不幸的是,从我做过的短暂研究中,它听起来像’Exit 225’就像是一个无法接受的错误代码,代码超出了可接受的代码范围.

整个问题的有趣部分是这样的:当我导航到/ home / apps / shout32 /文件夹,并在那里运行命令时,没有完整的路径…该死的东西有效:

root@streams3:/home/apps/shout32# ./sc_serv sc_plex.conf > /dev/null 2>&1 &
[2] 2245
root@streams3:/home/apps/shout32#
root@streams3:/home/apps/shout32# ps -C sc_serv
  PID TTY          TIME CMD
 2245 pts/0    00:00:00 sc_serv

因此,有些东西搞乱了,因为脚本文件位于/etc/init.d/而不是应用程序所在的文件夹中?据我所知,我遵循已发布的教程中的每一步,在Ubuntu中设置SHOUTcast,然后制作一个守护进程……我不认为我错过了什么.我有一种感觉,解决方案要么正好盯着我,要么是某种晦涩的权限,这有点让我头疼.

但任何帮助将不胜感激!

所以,基于下面的答案,我在我的脚本中添加了cd / home / apps / shout32 /到START命令,还添加了pwd和ls …以查看我们是否可以消除脚本无法找到/的事实日志/目录.

所以现在我的脚本是:

CONFIG="/home/apps/shout32/sc_plex.conf"
DAEMON="/home/apps/shout32/sc_serv"

cd /home/apps/shout32/

case "$1" in
        start)
                echo "Starting SC..."
                cd /home/apps/shout32/
                pwd
                ls
                $DAEMON $CONFIG &
                ;;
        stop)
                echo "Stopping SC..."
                kill -9 `ps -C sc_serv -o pid --no-headers`
                ;;
        restart)
                echo "Rebooting SC..."
                kill -9 `ps -C sc_serv -o pid --no-headers`
                $DAEMON $CONFIG &
                ;;
        *)
                echo "usage: service sc32d {start | stop | restart}"
                exit 1
                ;;
esac

我懂了:

admin@streams3:/etc/init.d$service sc32d start
Starting SC...
/home/apps/shout32
changes.txt     readme.txt                     sc_serv_debug.conf
config_builder  sc_plex.conf                   sc_serv_public.conf
control         sc_serv                        sc_serv_relay.conf
docs            sc_serv2_linux_07_31_2011.tar  sc_serv_simple.conf
logs            sc_serv_basic.conf             tos.txt
admin@streams3:/etc/init.d$2013-06-05 17:52:08      E       msg:<***>      logger could not open file logs/sc_serv.log
2013-06-05 17:52:08     I       msg:<***>       Logger shutdown

解决方法

你的第二个片段包含logger无法打开文件logs / sc_serv.log.因此,它尝试写入一个文件sc_serv.log,它要么想要或者想要在当前目录中预期的目录日志中创建它.这也解释了当你首先cd到/ home / apps / shout32 /它时它可以工作.我猜有一个文件/home/apps/shout32/logs/sc_serv.log.

你能配置那个文件的位置吗?你不能只在脚本开头添加一些CD吗?

(编辑:李大同)

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

    推荐文章
      热点阅读