相关疑难解决方法(0)

记录脚本输出的初始化脚本

如何才能做到这一点?我知道这很简单,包括在启动 init 脚本的实际命令中附加类似&&>的内容。

但是,假设日志文件是 /var/log/customDaemon.log ,最好的方法是什么,如何确保 init 脚本自行分离?

这是我拥有的初始化脚本。我也不确定脚本中的方法是整洁的还是只是一个讨厌的黑客。

#!/bin/bash
#
# /etc/rc.d/init.d/customDaemon
#
# description: "The Daemon"
# processname: customDaemon
# pidfile: "/var/run/customDaemon.pid"

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

start() {
    echo "Starting customDaemon"
    /var/customDaemon &> /dev/null &
    return 1
}

stop() {
    echo "Stopping tweriod"
    prockill customDaemon   
    return 2
}

case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        stop
        start
    ;;
    reload)
        restart
    ;;
    status)
        status customDaemon
    ;;
    *)
        echo "Usage: customDaemon …
Run Code Online (Sandbox Code Playgroud)

linux log-files logging daemon init

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

daemon ×1

init ×1

linux ×1

log-files ×1

logging ×1