- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Startup script
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
06-12-2005 11:46 AM
06-12-2005 11:46 AM
I have created a script but wants to execute during booting of the hpux 11i.
Can anyone suggest how to achieve this on hpux 11i ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 12:22 PM
06-12-2005 12:22 PM
SolutionIt must contain a start section and a stop section. See /sbin/init.d/template for an example.
To actually have it do something, for example start a server process at run level 3 and stop it at run level 2, this is an example with the ficticous service schmo
cd /sbin/rc3.d
ln -s /sbin/init.d/schmo S990scho
cd /sbin/rc2.d
ln -s /sbin/init.d/schmo K110scho
The K kills and the S starts.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 01:54 PM
06-12-2005 01:54 PM
Re: Startup script
Create a script which accepts start and stop as option for starting and stopping
(e.g. #script start =>will start the script)
Place this script in /sbin/init.d
Decide in which run level you want to start the script and any service and daemon required for script (e.g. inetd )Create a link in the run level directory
#ln -s /sbin/init.d/script /sbin/rc3.d/SXXXscript
XXX -is number which decides the order for executig the script (asending order) and S indicates the script will be started.
similarly for stopping use
#ln -s /sbin/init.d/script /sbin/rc2.d/KXXXscript
where XXX is again a no and K is to stop the script.
Cheers!!!
eknath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 01:57 PM
06-12-2005 01:57 PM
Re: Startup script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 05:23 PM
06-12-2005 05:23 PM
Re: Startup script
Copy your script in /sbin/init.d directory. Change the permission accordingly (execute permission is must)
Next is to decide at what runlevel the sscript should be executed. It depends on the nature of your scripts. If it depends on some subsystem to be up, then your script should be numbered in such a way as to exeute after that subsystem. Lets say the runlevel is N, that means the run level for stopping your script should be N-1.
Next is to decide the script number, this again depends on the dependencies of your script. Your start script number should be higher than that of any dependency script. Lets say you decide on M, then the kill script number would be 1000-M.
If you have configuration file, make sure to keep ti in /etc/rc.config.d/ directory. This will ensure that /sbin/rc source in your configuration before executing your script.
At the end the setup should look something like
/sbin/init.d/script
/sbin/rc{N}.d/S{M}script links to /sbin/init.d/script
/sbin/rc{N-1}.d/K{1000-M}script links to /sbin/init.d/script
You are done.
-Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 08:19 PM
06-12-2005 08:19 PM
Re: Startup script
The elegant way of running the script is to decide in which run level you want to start and use the /sbin/init.d, /etc/rc.config.d and /sbin/rc*.d paths as others have
suggested.
The other way would be to place a line for you script
in /etc/inittab file.
Please consult the man page of inittab for further details.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 08:42 PM
06-12-2005 08:42 PM
Re: Startup script
Please check the attachment.
Regards
Ganesha Sridhara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 10:17 PM
06-12-2005 10:17 PM
Re: Startup script
i will explain you in a 4 step process:
Step 1:Decide run level
a)whats started in run level2:
ls /sbin/rc2.d/S*
b)whats started in run level3:
ls /sbin/rc3.d/S*
it will list all the start process in that run level for eg;
/sbin/rc3.d/S100nfs.server
this file S100nfs.server is a link to /sbin/init.d/nfs.server
The start and stop scripts are numbered in such a fashion that their sum is 1000 for eg:
/sbin/rc3.d/S100nfs.server
/sbin/rc2.d/K900nfs.server
Step 2: write startup and shutdown script
you can use /sbin/init.d/template
copy this file as script name eg: web_server
and write a script
sample script
#!/bin/ksh
#
# Copyright(C) 2001 VERITAS Software Corporation. ALL RIGHTS RESERVED.
PATH=/usr/sbin:/usr/bin:/sbin; export PATH
mode=$1
case "$mode" in
'start_msg')
echo "Start WEB Server"
exit 0
;;
'stop_msg')
echo "Stop WEB Server"
exit 0
;;
'start')
/bin/nohup /opt/HPweb/bin/web_server >/dev/null 2>&1 &
;;
'stop')
/opt/HPweb/bin/web_server -k
;;
*)
echo "Usage: \$0 { start | stop }"
exit 1
;;
esac
exit 0
Then create a config file /etc/rc.config.d/web_server to tell the above script where to find the daemon.and whether to start or stop ?
cat /etc/rc.config.d/web_server
#!/sbin/sh
# $Header: /kahlua_src/web/server/etc/webadmin 72.1 1999/09/16 03:51:04 lancer E
xp $
# WebAdmin application server configuration.
#
# WEB_SERVER: Set to 1 to start the WebServer application server.
#
WEB_SERVER=1
note: its always a better idea to turn the script to 0 rather than deleting or moving the script, if you dont want to run the script.
Step 3: Create symbolic links
This will cause the script to run at the right place in the boot and shutdown sequences.
start process:
ln -s /sbin/init.d/web_server /sbin/rc2.d/S900web_server
kill process:
ln -s /sbin/init.d/web_server /sbin/rc1.d/K100web_server
(This script is for starting the web_server on run level 2 and stopping it on run level 1)
Step 4: Test the script
test the script on a test server . start and stop the daemon, run the script manually
by
/sbin/init.d/web_server
Reboot the server
Hope I have given you the step by step procedure... if anything is missed out pls update me to correct myself...
Regards and all the best
Vinod
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2005 02:17 AM
06-14-2005 02:17 AM
Re: Startup script
need to look again and again...
Good Luck,