1834008 Members
1771 Online
110063 Solutions
New Discussion

Writing a file at boot

 
SOLVED
Go to solution
TWBSupport
Regular Advisor

Writing a file at boot

I want my HPUX to write a new file to a users directory in home anytime it is bounced. I know this has to be extremely easy, but I'm having a heck of a time figuring the script out. Anyone already have something like this you wouldn't mind passing along? Thanks in advance.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Writing a file at boot

The most straightforward approach would be to create a file in /sbin/init.d/. There is a file there called "template" which should be copied to a new file in the same directory, e.g. "rebootnews". You then modify this file in the "start" section and possibly the "stop" section to append to your logfile when the box is coming up and going down. You next step is to symbolically link this file to an entry in one of the rcN.d directories. Because /home will needed to be mounted before you perform your task, I suggest that you link it like this:

ln -s /sbin/init.d/rebootnews /sbin/rc1.d/S120rebootnews

and for the "stop" message:
ln -s /sbin/init.d/rebootnews /sbin/rc0.d/K880rebootnews
If it ain't broke, I can fix that.
Peter Godron
Honored Contributor

Re: Writing a file at boot

Denda,
or, as long as you document it, modify one of the existing files. So, for example, if you have a Oracle startup/shutdown script add your command there.

echo `date` > $USER/`date +%y%m%d%H%M`.log

TWBSupport
Regular Advisor

Re: Writing a file at boot

Thanks to both of you! I guess I just needed a muse for brainblock and you both gave me different ideas on how I wanted to do it.

What I ended up doing is created a generic file, then created a script that copies that file into the users home drive in rc3.d, after Oracle has started, since I know that all directories have been mounted by this time.

The users script checks for this file and if it is there, deletes it, then starts a service that can not be started via HPUX startup. Thanks to both of you!