Starting service daemons

hinko.kocevar at cetrtapot.si hinko.kocevar at cetrtapot.si
Tue Mar 27 05:46:28 PDT 2007


Natanael Copa wrote:
> On Tue, 2007-03-27 at 13:56 +0200, hinko.kocevar at cetrtapot.si wrote:
>> Natanael Copa wrote:
>>> On Tue, 2007-03-27 at 13:28 +0200, hinko.kocevar at cetrtapot.si wrote:
>>>> Natanael Copa wrote:
>>>>> On Tue, 2007-03-27 at 09:16 +0200, hinko.kocevar at cetrtapot.si wrote:
>>>>>> Hello,
>>>>>>
>>>>> Use start-stop-daemon -n or with pidfiles.
>>>>>
>>>> Ok, thanx.
>>>> I've tried -m -p /var/lock/pidfile and strange thing happens - actual 
>>>> PID number recoreded in the pidfile doesn't belong to the daemon being 
>>>> started. It belongs to the process that already finished. Eg.
>>>>
>>>> # start-stop-daemon --start -m -p /var/lock/crond.pid -x /sbin/crond -- 
>>>> -c /etc/crontab/
>>>>
>>>> # ps
>>>> ...
>>>>   4274 root        192 S   /sbin/crond -c /etc/crontab/
>>>>
>>>> # cat /var/lock/crond.pid
>>>> 4272
>>>>
>>>> Note: I observed that this doesn't happen with dropbear client but with 
>>>> busybox applets - crond, httpd, ...
>>> Its normal. process forks, child continues, parent exits and the pid of
>>> parent get recorded.
>>>
>>> try start-stop-daemon -n
>>>
>> It doesn't help or I don't know how to use it :/
> 
> Then drop the pidfile (-p) and use -n only.

I can't start the service wo providing at least -x or -a along with the 
-n -- also isn't -n used for stopping the service?
> 
> alternatively you can drop start-stop-daemon:

I think I'm about to! I'm confused by the variety of switches and their 
combination...

> 
> DEAMON=httpd
> start() {
> 	if pidof $DAEMON >/dev/null ; then
> 		echo "already running"
> 		return 1
> 	else
> 		$DEAMON $OPTS
> 		return $?
> 	fi
> }
> 

Great! I've stumbled upon 'pidof' in one of the howtos on the net few 
minutes ago.

All I really need is to start a service and have its pid close and ready 
for quick extraction. using ps,grep,[sed|awk] everytime I want to 
manipulate process info is too slow on my embedded system so I'm looking 
for one-line even better one-command scripts :).

Thank you,
hinko
-- 

ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: hinko.kocevar at cetrtapot.si
Http: www.cetrtapot.si



More information about the busybox mailing list