0

I have a script foo which, if provided an argument start, starts, among other things a script bar in the background and exits - bar contains an infinite loop.

At a later stage, I want to call foo with argument stop and I would like that script bar, which still runs in the background stops running.

What is the text book way of achieving this?

1 Answer 1

1

To do this the way init scripts normally do, when foo starts bar, you should write the PID of bar to a file named /var/run/bar (or similar location depending on your OS). Then when you call foo stop, you read the PID and signal the bar process appropriately. Of course there are other solutions, but this seems to be a "textbook" answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .