1834757 Members
3060 Online
110070 Solutions
New Discussion

Processes in startup

 
SOLVED
Go to solution
Manuales
Super Advisor

Processes in startup

Hi ...
I have a script named start_procs.sh
I need put it in startup
on unix B.11.11

how can i do it?


Thanks.
7 REPLIES 7
Ninad_1
Honored Contributor
Solution

Re: Processes in startup

Hi,

Use the /sbin/init.d/template and copy as another filename - say - /sbin/init.d/myscript
Add your commands in the start and stop section for starting and stopping your script.
Then goto /sbin/rc3.d [ Assuming that you want to start the process at init level 3 ]
ln -s /sbin/init.d/myscript S900myscript
goto /sbin/rc0.d
ln -s /sbin/init.d/myscript K900myscript


Pls refer to this thread for more inputs and advices from others.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1029055

Regards,
Ninad
A. Clay Stephenson
Acclaimed Contributor

Re: Processes in startup

Go to /sbin/init.d and copy the file template to another file, e.g. myscript. In the start) section of this file is where you put the call to your script. Next decide upon the run-level that you want to start your script. Typically, run-level 3. Create a symbolic link to /sbin/init.d/rcN.d where N is the run-level.

e.g ln -s /sbin/init.d/myscript /sbin/rc3.d/S800myscript. If you also want to stop the process automatically then put the appropriate commands in the stop) section and create a symbolin link in the N-1 directory.
e.g ln -s /sbin/init.d/myscript /sbin/rc2.d/K200myscript.

Note that, by convention, your 3-digit 'S' value + your 3-digit 'K' value should add to 1000. This tends to make the start and stop occur in the correct order.
If it ain't broke, I can fix that.
Manuales
Super Advisor

Re: Processes in startup

Hi ...
thanks ...
i have other doubt, could be start processes from startup under an owner differet to root?

I mean, i require some processes be running with userid named "userprocs" which is differetn to root.

can i put these processes to be run into a script and they be run with other userid different to root?

Thanks.
A. Clay Stephenson
Acclaimed Contributor

Re: Processes in startup

The rcN.d scripts run as root but you can start your scripts within the rc scripts using an "su username -c command arg1 arg2 ..." command. It's normally not a good idea to use the "su - username -c command arg1 arg2 ..." method to execute username's .profile because the .profile will probably have commands (tset, stty, tput, tabs) that assume stdin is a terminal and will hand or fail otherwise. If you must set environment variables then set them explicitly in your script.
If it ain't broke, I can fix that.
Manuales
Super Advisor

Re: Processes in startup

Hi, acorddng is telling Clay, how must i use "su" command?
could you give an example please ?

"su username -c command arg1 arg2 ..."


thanks ...
A. Clay Stephenson
Acclaimed Contributor

Re: Processes in startup

It's quite simple. In your modified /sbin/init.d/ copy of the template file, look for the case statement with the start) section, you then add
su userprocs -c /xxx/yyy/start_procs.sh

NOTE: Your user "userprocs" violates the traditional 8 character login limit so it should be a shorter name. /xxx/yyy/start_procs.sh should be the absolute pathname to whereever your script is located and it should have an explicit "shebang" line like
#!/usr/sbin/sh
as the very first like of your script. Any needed arguments can also be passed to start_procs.sh as additional arguments following the command name in the su command.
If it ain't broke, I can fix that.
Manuales
Super Advisor

Re: Processes in startup

Dear A. Clay Stephenson:

Really, really thanks a lot for your definition about su command ... really you explains things an easy way!!!!
if i could give you more points, i will.

thanks !!!
Manuales.