Need help with rc.d script
Ernie Luzar
luzar722 at gmail.com
Thu Nov 9 14:55:05 UTC 2017
Thanks for everyones input. But still the service stop command can not
find the pid file.
In a effort for everyone to play with this problem on their own
computers I have simplified things as shown below.
>cat /usr/local/sbin/testloop
#!/bin/sh
(
while true; do
echo -e "Success:"
logger -t testloop -p daemon.err "Success: log"
sleep 10
done
) &
echo $! > /var/run/dynip.pid
exit 0
The above is what Iam said to try.
>cat /usr/local/etc/rc.d/testloop
#!/bin/sh
#
#
# PROVIDE: testloop
# REQUIRE: LOGIN DAEMON NETWORKING
# KEYWORD: nojail shutdown
#
# Add the following line to /etc/rc.conf to enable testloop:
#
# testloop_enable="YES"
#
. /etc/rc.subr
name="testloop"
rcvar=testloop_enable
pidfile="/var/run/${name}.pid"
command="/usr/local/sbin/${name}"
load_rc_config ${name}
run_rc_command "$1"
service testloop onestart does indeed start testloop as a daemon. Can
verify that by using the ps command. But there is no
/var/run/testloop.pid created, and the service testloop onestop command
still complains about it not running no pid file.
More information about the freebsd-questions
mailing list