如何才能做到这一点?我知道这很简单,包括在启动 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)