Operating System - HP-UX
1822430 Members
2882 Online
109642 Solutions
New Discussion юеВ

Cron started through inittab

 
SOLVED
Go to solution
LucianoCarvalho
Respected Contributor

Cron started through inittab

Hi Guys! Is there any restriction to configure cron to be started through inittab?? I configured a line like that "crn:3:respawn:/usr/sbin/cron". When I run "init q" to reread the inittab file, eight cron processes are been started, and after some time this number increases. Any idea?"
10 REPLIES 10
Hai Nguyen_1
Honored Contributor

Re: Cron started through inittab

Why do you want to start cron using init? There should already be a cron startup/shutdown. I have never seen a cron daemon die while a system stays up and running.

Hai
Helen French
Honored Contributor

Re: Cron started through inittab

Your way of setting up cron is not recommended. There is a cron startup script in /sbin/init.d/cron. This will start and stop during system shutdown and start. You don't need to set up through inittab file. Once the system started, the cron daemon will start running and if you want to add some new process in it, use 'crontab' command. Once you add it, it will start running from that moment.
Read man pages for a better idea:

# man cron
# man crontab
Life is a promise, fulfill it!
LucianoCarvalho
Respected Contributor

Re: Cron started through inittab

My boss want me to do that just to make sure that te daemon will not stop running.
If there is any restrinctin I can justify that this will not work, but I found nothing saying that I can't use cron in inittab.
Helen French
Honored Contributor

Re: Cron started through inittab

To your boss:

1) From man pages of cron (1m) - "Since cron never exits, it should be executed only once. This is best done by running cron from the initialization process with the startup script /sbin/init.d/cron (see init(1M))."

This answers his concerns about running cron indefenitely.

2) Adding processes/programs in /etc/inittab for startup is an old fashion way. It was used in older days but not now. You can easily manage and administrate rc scripts which is actually started by "rc" command in inittab.
Life is a promise, fulfill it!
Caesar_3
Esteemed Contributor

Re: Cron started through inittab

Hello!

I know this type of bosses so if they would
understand that cron never exit you can
change the startup script of cron or made
new one that will check if cron "exit"
start it again!

Caesar
James A. Donovan
Honored Contributor
Solution

Re: Cron started through inittab

Write yourself a little cron monitor script and start it at the same time you start cron...

example...

#!/bin/sh
while 1
do
ps -ef|grep /usr/sbin/cron|grep -v /usr/sbin/cron
if [ $? = 1 ]; then
/usr/sbin/cron
fi
done


...of course, you'll need to write a monitor script that monitors that the cron monitor is running, and so on, and so on....
Remember, wherever you go, there you are...
Dario_1
Trusted Contributor

Re: Cron started through inittab

Hi!

If this will make him/her feel better, just write a little monitoring script that will check if the cron daemon is running and have someone get an alert (page,email)if not or simply execute the startup script (/sbin/init.d/cron start)from that same monitoring script.

Regards,

DR
A. Clay Stephenson
Acclaimed Contributor

Re: Cron started through inittab

You seem to be trying to fix the symptoms rather than the problem itself. If the cron daemon is dying (or you are simply concerned that it might die) then:

1) Look for and install the latest cron cumulative patch.

2) Use the standard rc startup script but let it also start a daemon that does a ps -e grep' ing for cron and then sleeps for 600 seconds or so and checks again.



If it ain't broke, I can fix that.
Jack Werner
Frequent Advisor

Re: Cron started through inittab

To respondents that suggested creating/running a cron monitor script;

Is there a problem with using the :spawn: option on any stanza in the /etc/inittab file? Shouldn't :spawn: restart that process if it has (been) stopped for any reason? Look at other stanzas in inittab that use :spawn: and see if these processes can be re-spawned(ie restarted by the INIT process). I understand that /sbin/init.d contains system shutdown and startup scripts for most system processes, but has the :spawn: option been functionally supplanted by these scripts? I do not think so.
i'm retired
Sorrel G. Jakins
Valued Contributor

Re: Cron started through inittab

Write a script to go in every 5 minutes and check if cron is running.
If it is, send your boss an email.
If it isn't, restart it and send yourself a piece of mail.