[comp.unix.questions] How to kill cron and start cron again, using cron ?

geert@ahds.UUCP (Geert W.T. Jonkheer CCS/TS) (04/08/91)

For a reason, i want to kill cron(1) for a little moment and
then start it again (when there are now processes running, started
by cron).
As this must occur automatically (one's a year) , cron(1) must
be killed using cron(1). You can't use at(1) to kill 
cron, because atrun is also started from cron, thus this 
isn't a solution. 

The killing of cron, will succeed, but after it has been killed, 
it never starts up again. The program that killed cron, doesn't
run anymore, because it killed his parent 'cron'. 
I've tried to start cron(1) from init(1), using an 
inittab(4) entry for cron. I'll quote:

'cron:1:respawn:/etc/cron' 

But when i did this, cron(1) starts over 
and over again, apparently init(1) does not see that cron has 
already started yet.

Is there somebody who can help, any suggestions are welcome?

Thanks in advance.
 
Geert.

----------------------------------------------------------------------
Albert Heyn B.V. Zaandam.                  UUCP: ....!hp4nl!ahds!geert
The Netherlands. 
----------------------------------------------------------------------

barmar@think.com (Barry Margolin) (04/09/91)

In article <1933@ahds.UUCP> geert@ahds.UUCP (Geert W.T. Jonkheer CCS/TS) writes:
>For a reason, i want to kill cron(1) for a little moment and
>then start it again (when there are now processes running, started
>by cron).
...
>The killing of cron, will succeed, but after it has been killed, 
>it never starts up again. The program that killed cron, doesn't
>run anymore, because it killed his parent 'cron'. 

That seems strange.  Processes don't normally die just because their parent
died.

Maybe the signal is being propogated to the entire process group.  If this
is the problem, you can get around it by having the killer process get its
own process group.

>I've tried to start cron(1) from init(1), using an 
>inittab(4) entry for cron. I'll quote:
>
>'cron:1:respawn:/etc/cron' 
>
>But when i did this, cron(1) starts over 
>and over again, apparently init(1) does not see that cron has 
>already started yet.

Init(1) doesn't expect the command to exit until it is done.  Cron(1) forks
a background process and then the original process exits, so init(1) thinks
it is done and runs it again.
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar