- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to start a script during the boot at run level...
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-16-2002 04:13 AM
04-16-2002 04:13 AM
We know that we have to put the link in /sbin/rc3.d but we don't know how to do it and if we need to do something else. Please help us. Thanks a lots.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:19 AM
04-16-2002 04:19 AM
Re: how to start a script during the boot at run level 3
It's like you said, create a link in this directory to the startup file of what you want to start.
the start files should be named
S[unique_number][command_name]
See man ln for how to use the command
(ln -s [file1] [file2])
Also you need to do the same for the kill script.
these files (used to kill the proces should be named K[unique_number][process_name]
HTH, Emiel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:23 AM
04-16-2002 04:23 AM
Re: how to start a script during the boot at run level 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:23 AM
04-16-2002 04:23 AM
Re: how to start a script during the boot at run level 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:24 AM
04-16-2002 04:24 AM
Re: how to start a script during the boot at run level 3
/sbin/init.d contains the actual rc scripts. You should have one named "template" to use as an example for creating your /sbin/init.d script.
Then create a symlink in /sbin/rc3.d for starting the script and one in /sbin/rc2.d for stopping it.
Example:
cd /sbin/init.d
cp -p template myscript
make your changes to myscript
ln -s /sbin/init.d/myscript /sbin/rc3.d/S900myscript
ln -s /sbin/init.d/myscript /sbin/rc2.d/K100myscript
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:24 AM
04-16-2002 04:24 AM
Re: how to start a script during the boot at run level 3
(1) Most scripts called at start up through the rcX.d directories are placed in /sbin/init.d, and are then linked to the appropriate rcX.d directory. Those scripts should contain a case statement at least 'start' and 'stop' as arguements.
(2) A sample script can be found at /sbin/init.d/template. That script *must* be edited a lot, but has the format you probably want to use.
Good Luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:25 AM
04-16-2002 04:25 AM
Re: how to start a script during the boot at run level 3
put the script in
/sbin/init.d
create start link in /sbin/rc3.d/
the name of the link has to start with a "S" followed by a number. The number you specify will adjust the startup sequence so the highest number will be started last.
# cd /sbin/rc3.d
# ln -s /sbin/init.d/<scriptname> /sbin/rc3.d/S???<scriptname>
You should also create an halt ( kill ) script to stop the software.
These scripts start with a K??? ( 1000 - Snumber).
Put a link in rc2.d:
ln -s /sbin/init.d/<scriptname> /sbin/rc2.d/K???<scriptname>
Hope this will help,
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:26 AM
04-16-2002 04:26 AM
Re: how to start a script during the boot at run level 3
I would recommend using the template script, this can be found as /sbin/init.d/template
Now in /sbin/rc3.d for example you would create the link as such ..
# ln -s /sbin/init.d/myscript S995myscript
and in /sbin/rc2.d you would create the "kill" script link as such ..
# ln -s /sbin/init.d/myscript K199myscript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:27 AM
04-16-2002 04:27 AM
Re: how to start a script during the boot at run level 3
If you haven't, read either version of the document below. I???ll summarize the key points here.
/usr/share/doc/start_up.txt
http://docs.hp.com/hpux/onlinedocs/os/startup.html
The file /sbin/init.d/template is a good starting place for making your own start/stop scripts.
The /sbin/init.d directory contains all scripts used to startup and shutdown various subsystems.
Each script under /sbin/init.d should perform BOTH the startup and shutdown functions. In order to control the functionality within the script, each must also support standard arguments and exit codes. Scripts must be written for the POSIX shell. A template script may be found in /sbin/init.d/template.
There is no reason why the startup and shutdown script cannot start/kill multiple, but related processes. Remember to choose the appropriate rc
Each script in /sbin/init.d performs BOTH the startup and shutdown functions, and each will have two links pointing towards the script from /sbin/rc*.d: one for the start action and one for the stop action.
Start scripts begin with "S"; Kill (stop) scripts begin with "K". The order of execution for kill scripts is the reverse of the startup ones.
if a start script is placed in directory '/sbin/rc{X}.d' then its corresponding kill script is put in directory '/sbin/rc{X-1}.d'
A general rule-of-thumb is that the sequence number of the start script plus the sequence number of the kill script should add to 1000.
Subsystems should be killed in the opposite order they were started. This implies that kill scripts will generally not have the same numbers as their start script counterparts. If two subsystems must be started in a given order due to dependencies (e.g., S200sys1 followed by S300uses_sys1), the counterparts to these scripts must be numbered so that the subsystems are stopped in the opposite order in which they were started (e.g., K700uses_sys1 followed by K800sys1). The '1000' rule leads to this behavior.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 04:29 AM
04-16-2002 04:29 AM
Re: how to start a script during the boot at run level 3
Place your script in /sbin/init.d (have a look at other scripts in that directory to get the correct format).
Then make a link to your script from /sbin/rc3.d (for run-level 3), name the link S999xxxxx where 999 is a unique number and xxxxx is the script name.
NOTE that scripts are executed in numerical order.
Also make a link in /sbin/rc2.d, nake this link K999xxxxx - this will stop the script when you move from run-level 3 down to run-level 2.
Check man ln for details of how to make the links.
HTH,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 05:56 AM
04-16-2002 05:56 AM
Re: how to start a script during the boot at run level 3
1)
set_return()..
x=$?
.....
fi
what does x=$? mean?
2)
if [ -f /etc/rc.config.d/cron ]; then
. /etc/rc.config.d/cron
else....
what does . /etc/rc.config.d/cron mean?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 06:03 AM
04-16-2002 06:03 AM
Solution1)
set_return()..
x=$?
.....
fi
what does x=$? mean?
$? is the return value of the command.
0=completed successfully
1=had errors
2)
if [ -f /etc/rc.config.d/cron ]; then
. /etc/rc.config.d/cron
else....
what does . /etc/rc.config.d/cron mean?
It means get the variables from the file. Normally the rc.config.d directory contains files that have specific configuration variables for the rc script.
Hope this helps,
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 06:04 AM
04-16-2002 06:04 AM
Re: how to start a script during the boot at run level 3
2) ". /path/script" means that the script is 'sourced', i.e. it is read by the current shell instead of by a (shell) child of the current shell. It is done when things must be done in the current shell, like for example setting environment variables which have to be exported (because you can export to a child but not from a child to a parent).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 06:07 AM
04-16-2002 06:07 AM
Re: how to start a script during the boot at run level 3
what does x=$? mean?
$? is the status of the last command; by convention, 0 usually indicates success and any other value indicates failure BUT while that may almost always be true you need to man the command to know for sure.
if [ -f /etc/rc.config.d/cron ]; then
. /etc/rc.config.d/cron
else....
The -f ... part tests whether the file /etc/rc/config.d/cron exists and if it is a regular file (as opposed to a directory, for example).
. /etc/rc.config.d/cron tells the shell to include /etc/rc.config.d/cron as part of the current shell. It is not started as a child process but rather is 'sourced' and becomes simply a part of the current shell. It is important that there is no unintended 'exit' statement in this 'sourced' file or you will exit both the 'sourced' file and the current shell since they are now one and the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 07:03 AM
04-16-2002 07:03 AM
Re: how to start a script during the boot at run level 3
if [ "$CRON" -eq 1 -a -x /usr/sbin/cron ];....
what does -a -x file mean?
Where can we usually find out this kind of informations?
Thanks very much from the happy italian guys
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 07:06 AM
04-16-2002 07:06 AM
Re: how to start a script during the boot at run level 3
if [ "$CRON" -eq 1 -a -x /usr/sbin/cron ];....
This expression tests the variable CRON for equality to one (1) AND ('-a') tests whether or not the file /usr/sbin/cron is executable ('-x').
Have a look at the man pages for 'test'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2002 11:03 AM
04-16-2002 11:03 AM
Re: how to start a script during the boot at run level 3
Good luck