Operating System - HP-UX
1835673 Members
2589 Online
110082 Solutions
New Discussion

Re: rc3.d script preventing server from rebooting ?

 
Lor
Frequent Advisor

rc3.d script preventing server from rebooting ?

I faced an issue yesterday and I would like to understand more about it.

Following script was created few months ago to add some kind of date stamp in dmesg output and runs fine.
Looping program is as follow :
#!/bin/ksh
while true
/usr/bin/sleep 60
/usr/bin/date
/usr/sbin/dmesg -
echo
done >> /var/adm/syslog/dated_dmesg.log

What happened yesterday is that this script in rc3.d would prevent server from booting to
default inittab level 3.

Why does the script cause server not to at least go to run level 1 and 2 (enabling network access).
Server reboot process would completely freeze
the server.

Solution was to boot single user, then init 2 then remove script in rc3.d and manually run init 3.

I presume I have to run script in nohup mode now but still I don't understand why server was not even running lower 1 and 2 rc levels.
4 REPLIES 4
Michael Schulte zur Sur
Honored Contributor

Re: rc3.d script preventing server from rebooting ?

Hi,

I think, you have to run the script in background. So put the lines in another file and call it from the script in rc3.d
like
nohup timestamp > /dev/null 2>&1
There is also a do missing.

greetings,

Michael
Steven E. Protter
Exalted Contributor

Re: rc3.d script preventing server from rebooting ?

You shoudn't run scripts with sleep commands in them in rc3.d

This is something you would be better off running as a cron job on a schedule.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Hassell
Honored Contributor

Re: rc3.d script preventing server from rebooting ?

The entire design of start/stop scripts in HP-UX is to not have plain scripts in the /sbin/rc?.d directories. Instead, scripts are stored in /sbin/init.d and sequencing links are placed in rc?.d directories. However, this script is a cron job that got misplaced. In fact, this job is so common that the template for root's cron has had this as an example for more than 10 years. See /usr/newconfig/var/spool/cron/crontab.root

The admin who wrote it is probably more familiar with other flavors of Unix. Remove the file completely and put this one line in crontab:

05,10,15,20,25,30,35,40,45,50,55 * * * * /sbin/dmesg - >> /var/adm/dmesg.log

Now to emulate what the script was doing, you could change the entry to:

* * * * * /sbin/dmesg - >> /var/adm/dmesg.log

so that dmesg runs every minute but I find that 5 mins is a reasonably small interval. Note that in the script above, your dated_dmesg.log file will have hundreds of dates but no text since dmesg is mostly silent. However, dmesg - already sends a date (mon, day, hr:min) with the messages but only when there is something to display. Thus, dmesg - already timestamps the output (dmesg without - does not).


Bill Hassell, sysadmin
John Palmer
Honored Contributor

Re: rc3.d script preventing server from rebooting ?

Startup scripts should be written to a standard defined by HP (see man rc).

In particular, they should be able to process the arguments start|stop|start_msg|stop_mesg.

rc calls all relevant scripts with the argument 'start_msg' to get the list of actions that it will perform at bootup.

I suspect that rc called
You must either amend your script to accept those arguments or (better in my opinion) scedule it to run every minute from cron.

Regards,
John