Hi morgon,
ikegami already said it, but in the module's source you can see that do_stop is the only place unlink is called on the PID file.
Taking a step back though: I understand that your process is something that just runs once briefly and then exits. Aside from the question as to whether you need a PID file in the first place (is your script called multiple times?) and whether you need to delete the PID file at all, I wouldn't really see the task you describe as a continually-running daemon - instead I might just set that up via cron.
Is this something like "dvbdate" (1, 2)? If so, that can be set up to run regularly in the crontab - which by the way also has a @reboot directive for running things once on startup (haven't used that myself but it sounds pretty simple).
If you really want to use an init script (which has the advantage that it can be run immediately on boot and you can control the prerequisites), you could use Daemon::Control's ability to generate an init script for you, and then adapt that to suit your needs. For example, if I use the get_init_file command on your script, I get something like this (edited for brevity):
#!/bin/sh ### BEGIN INIT INFO # Provides: Time from DVB # Required-Start: $syslog $remote_fs # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO` if [ -x /tmp/timeset_daemon.pl ]; then /tmp/timeset_daemon.pl $1 else echo "Required program /tmp/timeset_daemon.pl not found!" exit 1; fi
Then, just replace /tmp/timeset_daemon.pl by whatever command sets the time from the DVB stick, and it'll be run once on boot (and on shutdown, but that shouldn't matter here). Another sample init script is shown in this article, it also shows the usage of the update-rc.d command. You could also teach that script to respect the start|stop|status commands, but since your script isn't really a continually-running daemon, Daemon::Control might not be the optimal way to do that. Or, you can slap a while (1) { my_code_here; sleep($interval) } around your code and you've basically got a daemon.
I just recently started working with chrony to replace ntpd and provide accurate time via a GPS receiver on a Raspberry Pi, and it really was much easier to set up than ntpd. If you're looking into giving your RPi accurate time, then somehow feeding the DVB stick's time into chrony might be something worth investigating.
Hope this helps,
-- Hauke D
In reply to Re: Daemon::Control pid-files
by haukex
in thread Daemon::Control pid-files
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |