- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script okay when changing run levels but not boot ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 12:36 AM
04-03-2002 12:36 AM
I have a script which I would like to start automatically when my system boots. I've created a stop/start script (placed in /sbin/init.d) and added the appropriate S* and K* files (in /sbin/rc2.d and rc3.d) which link to it. To start my script it uses the command: /myscriptname >/dev/null 2>errorfile &
My problem is that when I change run levels ie. 3->1->3 or 3->2->3 the script is started and stopped fine, however when I re-boot the system my script is started okay, but then stops soon after (I can tell this by files that are created). Is there something different about the enviroment perhaps or the way the init process works at boot-up?
Any other ideas?
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 12:50 AM
04-03-2002 12:50 AM
Re: Script okay when changing run levels but not boot up!
Check $PATH at boot time (which is minimal). For debugging add set -x to your script and then check the error logfile.
HtH,
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 12:55 AM
04-03-2002 12:55 AM
Re: Script okay when changing run levels but not boot up!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:03 AM
04-03-2002 01:03 AM
Re: Script okay when changing run levels but not boot up!
I've checked /etc/rc.log and that just shows that the script started okay which makes sense as I know it starts, it just then stops a little later.
I'm just going to re-boot now with set -x on to check the output from both scripts. Sorry for being dim, but how do I check the $PATH at boot time? Also could this be related to the terminal which starts the script? (just a guess as I'm a novice!)
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:12 AM
04-03-2002 01:12 AM
Re: Script okay when changing run levels but not boot up!
Are there any terminal related commands in your script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:35 AM
04-03-2002 01:35 AM
Re: Script okay when changing run levels but not boot up!
Yes I agree, I should see some output in /etc/rc.log if the problem was path related.
Looking in rc.log after setting set -x, the following was produced exactly the same for changing run-levels and re-boot:
Start filtering script for MC trace_text (filter_tt)
Output from "/sbin/rc3.d/S050filter_trace_text start":
----------------------------
+ echo filter_tt started
+ /usr/contrib/scripts/filter_tt/filter_tt
filter_tt started
+ exit 0
+ 1> /tmp/filtout
This all looks okay to me.
Regarding 'terminal type' commands in my main script, I have several echo's, but these are all redirected to a file so avoid stdout. Checking the output of my main script after setting set -x on, I found that it stop working on a sleep command. Is sleep perhaps the problem?
Thank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:53 AM
04-03-2002 01:53 AM
Re: Script okay when changing run levels but not boot up!
It all looks fine.
Sleep will halt processing for the amount of time specified and should continue afterwards.
Since you start your script (filter_tt) in the background you should use exit 4 i.s.o. 0 :
The return values for startup scripts are as follows:
0 Script exited without error.
1 Script encountered errors.
2 Script was skipped due to overriding control variables from
/etc/rc.config.d files, or for other reasons, and did not
actually do anything.
4 Script exited without error and started a process in
background mode.
See man rc.
What's in /tmp/filtout and errorfile ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 02:29 AM
04-03-2002 02:29 AM
Re: Script okay when changing run levels but not boot up!
/tmp/filtout is empty, and errorfile just contains the debugged commands ending in + sleep 60.
I just tried setting exit 4 and this is the output:
+ echo filter_tt started
filter_tt started
+ rval=4
+ exit 4
+ /usr/contrib/scripts/filter_tt/filter_tt
"/sbin/rc3.d/S050filter_trace_text start" FAILED
+ 1> /tmp/filtout
Does that make sense? I checked the errorfile and /tmp/filtout and these had no clues. If I change run-levels up and down the output changes slightly to:
+ echo filter_tt started
filter_tt started
+ rval=4
+ exit 4
+ /usr/contrib/scripts/filter_tt/filter_tt
"/sbin/rc3.d/S050filter_trace_text start" FAILED
+ 1> /tmp/filtout
In both cases the outcomes are the same, i.e changing run-level works, re-boot doesn't!
thank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 03:44 AM
04-03-2002 03:44 AM
Re: Script okay when changing run levels but not boot up!
Are you on 10.20 ? Since that release does not have the "exit 4" option.
What comes after the sleep 60 command ?
Is /usr/contrib/scripts/filter_tt/filter_tt still running ? (check with ps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 03:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 04:03 AM
04-03-2002 04:03 AM
Re: Script okay when changing run levels but not boot up!
I'm on 11i and the man page for rc checks out fine saying I can use exit 4. Very peculiar.
The next line after the sleep 60 is back at the top of a while loop:
new_num_lines=`wc -l $file_name | cut -f 1 -d " " `
Nothing strange there I don't think either. filter_tt is still running if I have just changed run-levels but not on reboot.
thanks
Hello Duncan,
I tried nohup originally and then was advised that putting in the background was better. How can I direct the nohup.out to a specific location?
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 04:54 AM
04-03-2002 04:54 AM
Re: Script okay when changing run levels but not boot up!
I still think it has something to do with the process parent-child relation. What is the parent process of filter_tt when changing run levels ?
When you redirect the output when using nohup no nohup.out file will be created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 05:01 AM
04-03-2002 05:01 AM
Re: Script okay when changing run levels but not boot up!
From the nohup man page:
nohup executes command with hangups and quits ignored. If output is
not redirected by the user, both standard output and standard error
are sent to nohup.out.
As it looks like you are already re-directing your stdout & stderr elsewhere, don't worry about nohup.out.
HTH
Duncan
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 05:12 AM
04-03-2002 05:12 AM
Re: Script okay when changing run levels but not boot up!
Yes I agree this definetly looks like a parent-child problem. I'm pretty new to HP-UX but I've come across similar problems on other systems so I'm sure this is tied in somehow.
I have tried using nohup and this works okay in changing run-levels and re-booting which is good so I'll have to go with this method for now.
When I change run levels the parent process pid is 1 (with and without nohup) which is what you'd expect I guess.
Thanks