On Wed, Mar 31, 2010 at 3:55 AM, Murali K. Vemuri <[email protected]> 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.
>
> 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.

Looks like you want to run these using runsv (possibly with runsvdir).
See examples/var_service/*.

Basically, "runsvdir examples/var_service" would start
"runsv examples/var_service/SUBDIR" for every SUBDIR,
each of those will run examples/var_service/SUBDIR/run
and when it exits, rerun it again. "sv" tool controls these
services. For example, sv d DIR stops service in DIR.

Let me know if documentation on them is missing or inadequate.

> In the second case, I use "watch -t -n 25 process2" and that serves my
> purpose.

Wrong tool for the job.

> BTW, I made a small change in watch.c when -t option is used.
>
> orig code:
>
>        if (!(opt & 0x2)) { // no -t
>            const unsigned time_len = sizeof("1234-67-90 23:56:89");
>            time_t t;
>
>            // STDERR_FILENO is procps3 compat:
>            // "watch ls 2>/dev/null" does not detect tty size
>            get_terminal_width_height(STDERR_FILENO, &new_width, NULL);
>            if (new_width != width) {
>                width = new_width;
>                free(header);
>                header = xasprintf("Every %us: %-*s", period,
> (int)width, cmd);
>            }
>            time(&t);
>            if (time_len < width)
>                strftime(header + width - time_len, time_len,
>                    "%Y-%m-%d %H:%M:%S", localtime(&t));
>
>            // compat: empty line between header and cmd output
>            printf("%s\n\n", header);
>        }
>        fflush_all();
>
> my change:
>
>    move the fflush_all() into the if condition like this:
>
>        if (!(opt & 0x2)) { // no -t
>            const unsigned time_len = sizeof("1234-67-90 23:56:89");
>            time_t t;
>            fflush_all();
> ....
> .....
>        }

Why is this needed/useful?

> The user specifies the -t option only if he wants to do the "watch"
> silently. if the screen refreshes every often, does not look nice.

Why do you think -t means "watch silently"?

-- 
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to