Operating System - HP-UX
1821639 Members
3325 Online
109633 Solutions
New Discussion юеВ

How to put timestamp in /etc/rc.log

 
SOLVED
Go to solution
SKSingh_1
Frequent Advisor

How to put timestamp in /etc/rc.log

Hi All,

whether its possible to put timestamp in rc.log. mean whenever a rc script start executing while shutdown/bootup, it should put execution start time in rc.log.
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor

Re: How to put timestamp in /etc/rc.log

Hi:

You could do this if you wanted, but why? At the beginning of the current '/etc/rc.log' is a timestamp.

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: How to put timestamp in /etc/rc.log

Shalom,

The rc.log file is a sequential record of the boot.

If you want more, feel free to add `date` >> /etc/rc.log to any startup script you want.

Most of the daemons started have their own logs, so if you look around, you can find the time everything started or did not start. It requires a bit more system knowledge, but its helpful in doing hte job.

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
SKSingh_1
Frequent Advisor

Re: How to put timestamp in /etc/rc.log

Many of the times rc script may not have a daemon running.

The requirement is in cases where server boot takes relatively longer time. If we have time stamp we can trace easily, which process/rc-script caused the delay.
VK2COT
Honored Contributor

Re: How to put timestamp in /etc/rc.log

Hello,

Our colleagues already gave you the bad news :) There are no timestamps in /etc/rc.log by
current design.

To debug the boot processes, there are some simple techniques that can help (apart from changing every RC script):

a) Run the following:

# ll -ut /sbin/init.d

Assuming that no-one has opened any files in /sbin/init.d since the boot, a single "ll -ut" will show the time they were last ran.

b) Check /etc/utmp file using the fwtmp(1)
command. This will not help with startup
scripts but with the commands ran by
init(1) early in the boot before the RC scripts are started.

# /usr/sbin/acct/fwtmp < /etc/utmp

Here is an excerpt from a SuperDome nPar:

system boot 0 2 0000 0000 1190380685 Sep 21 23:18:05 2007
run-level 3 0 1 0063 0123 1190380685 Sep 21 23:18:05 2007
vxenable vxen 98 8 0000 0000 1190380685 Sep 21 23:18:05 2007
bcheckrc brc1 99 8 0000 0000 1190380704 Sep 21 23:18:24 2007
cat cprt 146 8 0000 0000 1190380704 Sep 21 23:18:24 2007
rm ems1 147 8 0000 0000 1190380704 Sep 21 23:18:24 2007
cat ems2 148 8 0000 0000 1190380704 Sep 21 23:18:24 2007
sh link 149 8 0000 0000 1190380704 Sep 21 23:18:24 2007
rc sqnc 153 8 0000 0000 1190381060 Sep 21 23:24:20 2007
old time 0 3 0000 0000 1190381018 Sep 21 23:23:38 2007
new time 0 4 0000 0000 1190381019 Sep 21 23:23:39 2007
getty cons 1938 5 0000 0000 1190381060 Sep 21 23:24:20 2007
krsd krsd 1939 5 0000 0000 1190381060 Sep 21 23:24:20 2007
sfd sfd 1940 5 0000 0000 1190381060 Sep 21 23:24:20 2007
cimserve cim1 1941 5 0000 0000 1190381060 Sep 21 23:24:20 2007
sh ems3 1942 8 0000 0000 1190381060 Sep 21 23:24:20 2007
p_client ems4 1945 5 0000 0000 1190381060 Sep 21 23:24:20 2007

Cheers,

VK2COT
VK2COT - Dusan Baljevic
SKSingh_1
Frequent Advisor

Re: How to put timestamp in /etc/rc.log

todays environment is complex. we have many database, batch participating in server shutdown/bootup. We are frequently getting issue for delayed server reboot.

so, need to have a quick check process and thats why timestamp is required.
Marlou Everson
Trusted Contributor
Solution

Re: How to put timestamp in /etc/rc.log

I have done exactly what you asked for. I have modified /sbin/rc.utils to put a timestamp on each step. It is very useful to see which process takes so long.

I keep a copy of the orig and local customized file.

-r--r--r-- 1 bin sys 21742 Oct 11 11:33 rc.utils
-r--r--r-- 1 bin sys 21742 Oct 11 11:33 rc.utils.local
-r--r--r-- 1 bin sys 21454 Jan 2 2004 rc.utils.orig

Here is what I did, the difference between the files.

diff rc.utils.orig rc.utils
617c617
< echo "----------------------------" >> $LOGFILE
---
> echo "---------------------------- "$(date) >> $LOGFILE
747c747
< echo "----------------------------" >> $LOGFILE
---
> echo "---------------------------- "$(date) >> $LOGFILE

Of course, you need to make sure you keep the same permissions, etc., and check when the system is patched if the rc.utils file has been changed.

I also keep more copies of the old rc.log files by expanding the "Initialize log file." section.

# Initialize log file.
if [ "$1" = "boot" ]; then
if [ -f "${LOGFILE}.old.2" ]; then
cat ${LOGFILE}.old.2 > ${LOGFILE}.old.3
fi
if [ -f "${LOGFILE}.old.1" ]; then
cat ${LOGFILE}.old.1 > ${LOGFILE}.old.2
fi
if [ -f "${LOGFILE}.old" ]; then
cat ${LOGFILE}.old > ${LOGFILE}.old.1
fi
if [ -f "${LOGFILE}" ]; then
cat ${LOGFILE} > ${LOGFILE}.old
echo "Old ${LOGFILE} moved to ${LOGFILE}.old" > ${LOGFILE}
fi
fi

Hope this is helpful.

Marlou
Geoff Wild
Honored Contributor

Re: How to put timestamp in /etc/rc.log

Can you just add a

print -s $(date) >>/etc/rc.log

at the start or end of the rc scripts...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
SKSingh_1
Frequent Advisor

Re: How to put timestamp in /etc/rc.log

Hi morlou, thank you for fantastic solution. I assuming only one file rc.utils needs to be modified to get timestamp of each rc script running at bootup/shutdown in rc.log.

PLease correct if I am wrong?
Marlou Everson
Trusted Contributor

Re: How to put timestamp in /etc/rc.log

Yes, just /sbin/rc.utils. The /etc/rc.log will look something like this:

Old /etc/rc.log moved to /etc/rc.log.old

**************************************************
HP-UX Start-up in progress
Wed Oct 17 16:09:54 PDT 2007
**************************************************

Configure system crash dumps
Output from "/sbin/rc1.d/S080crashconf start":
---------------------------- Wed Oct 17 16:09:55 PDT 2007
EXIT CODE: 0

Removing old vxvm files
Output from "/sbin/rc1.d/S090sw_clean_vxvm start":
---------------------------- Wed Oct 17 16:09:56 PDT 2007

VxVM device node check
Output from "/sbin/rc1.d/S091vxvm-nodes-check start":
---------------------------- Wed Oct 17 16:09:56 PDT 2007

I've been using this on my systems for quite a while. Now if HP would put it in permanently that would be great.

Marlou
Dennis Handly
Acclaimed Contributor

Re: How to put timestamp in /etc/rc.log

>Marlou: Now if HP would put it in permanently that would be great.

Have you contacted the Response Center and filed an enhancement request?
Either you or SKSingh.
SKSingh_1
Frequent Advisor

Re: How to put timestamp in /etc/rc.log

Thank you all. Solution received.
I am not sure, how to put enhancement request form.
Marlou Everson
Trusted Contributor

Re: How to put timestamp in /etc/rc.log

Dennis - No, I haven't. I hesitate to do so because it does not take me that long to modify the file and I find that explaining a non-problem to HP can be as frustrating as explaining a real problem. And the enhancement could take many months/years to happen. Of course, with 20 some odd systems and growing, it might be worth my time. :)

Marlou
Dennis Handly
Acclaimed Contributor

Re: How to put timestamp in /etc/rc.log

>I am not sure, how to put enhancement request form.

If you have support contract, you can call the Response Center or you can use the "Support Case Manager" link on the HP-UX forum page:
http://www1.itrc.hp.com/service/mcm/homepageRequest.do?lb=on