Re: Problem with start-stop-daemon and pidfile
>>>>> " " == Adam Heath <adam@doogie.org> writes:
> On 3 Jan 2001, Goswin Brederlow wrote:
>> Hi,
>>
>> I want to use start-stop-daemon to start the debian-mirror
>> script if its not already running. I don't trust the script, so
>> I run it as user mirror:nogroup.
>>
>> But then start-stop-daemon can't write a pidfile to /var/run.
>>
>> Whats the right[tm] way for this?
>>
>> root:~% start-stop-daemon -S -m -c mirror:nogroup -u mirror -p
>> /var/run/debian-mirror.pid -x /usr/sbin/debian-mirror
>> start-stop-daemon: Unable to open pidfile
>> `/var/run/debian-mirror.pid' for writing: Permission denied
> Touch the file first, then chown it, before calling s-s-d.
Ok, that helps somewhat. But now start-stop-daemon allways starts the
script.
----------------------------------------------------------------------
#!/bin/sh
#
# debian-mirror cron script
#
# This will start the debian-mirror script to update the local debian
# mirror, unless its still running.
set -e
test -x /usr/sbin/debian-mirror || exit 0
touch /var/run/debian-mirror.pid
chown mirror.nogroup /var/run/debian-mirror.pid
touch /var/log/debian-mirror.log
chown mirror.nogroup /var/log/debian-mirror.log
start-stop-daemon -S -m -c mirror:nogroup -u mirror -p /var/run/debian-mirror.pid -x /usr/sbin/debian-mirror >>/var/log/debian-mirror.log &
----------------------------------------------------------------------
Thats how I start the script know and "ps aux" shows:
mirror 20123 0.5 0.4 2076 1044 pts/3 S 02:07 0:00 sh -e /usr/sbin/debian-mirror
mirror 20125 0.2 0.2 1516 640 pts/3 S 02:07 0:00 rsync -rlpt --partial -v --progress --exclude Packages --delete ftp.de.debian.org :debian/dists/sid/Contents-i386.gz /mnt/raid/rsync-mirror/debian/dists/sid/
and cat /var/run/debian-mirror.pid:
20123
But running the script again starts a new instance:
mirror 20123 0.0 0.4 2076 1044 pts/3 S 02:07 0:00 sh -e /usr/sbin/debian-mirror
mirror 20135 0.1 0.4 2076 1044 pts/3 S 02:07 0:00 sh -e /usr/sbin/debian-mirror
mirror 20137 0.0 0.2 1516 696 pts/3 S 02:07 0:00 rsync -rlpt --partial -v --progress --exclude Packages --delete ftp.de.debian.org :debian/dists/sid/Contents-i386.gz /mnt/raid/rsync-mirror/debian/dists/sid/
mirror 20143 0.0 0.2 1516 668 pts/3 S 02:08 0:00 rsync -rlpt --partial -v --progress --exclude Packages --delete ftp.de.debian.org :debian-non-US/dists/sid/non-US/Contents-i386.gz /mnt/raid/rsync-mirror/debian/non-US/dists/sid/non-US/
and cat /var/run/debian-mirror.pid:
20135
So what am I doing wrong there?
MfG
Goswin
Reply to: