run a process

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Wed Mar 31 17:11:21 UTC 2010


On Wed, Mar 31, 2010 at 12:24:21PM +0900, Murali K. Vemuri wrote:
>unfortunately, my process does not block. So, I cannot use "watch" on
>it.
>is there any alternative applet to do this?
>
>Thanks & regards
>Murali
>
>On Tue, 2010-03-30 at 21:54 -0500, Rob Landley wrote:
>> On Tuesday 30 March 2010 20:55:50 Murali K. Vemuri wrote:
>> > Hi ,
>> >
>> > I use busybox version 1.16.1.
>> > I have two processes that have to be running all the time, but with some
>> > differences in behavior.
>> >
>> > process 1: This process must be up and running all the time, but need
>> > not be re-run every now and then. All I need is to ensure this process
>> > exits, its automatically re-run.

/etc/inittab:
null::respawn:/usr/local/sbin/my_process1
(assuming it doesn't need a tty)
>> >
>> > process 2: this process has a life span of about 20 seconds. So, I need
>> > to make sure every 20 sec, this is run. This process exits
>> > automatically.

if you want to automatically respawn it then i'd just respawn it like
process1. If you need a delay between runs, then respawn a script that
does something like:
cat /usr/local/sbin/my_process2.sh<<EOF
#!/bin/sh
/usr/local/sbin/my_process2
sleep 5
EOF
chmod +x /usr/local/sbin/my_process2.sh

See examples/inittab for further details on how to configure init.

>> >
>> > In the second case, I use "watch -t -n 25 process2" and that serves my
>> > purpose.
>> > But how do I achieve the process 1 functionality?
>> 
>> If your process blocks, "watch -n 1 your process should work" just in the first 
>> case as in the second.  Watch won't interrupt it if it takes longer than 1 
>> second to run, that's just how long it blocks between invocations.
>> 
>> Try "watch -n 1 sleep 10" to see what I mean.


More information about the busybox mailing list