Operating System - Linux
1828490 Members
2306 Online
109978 Solutions
New Discussion

Re: which is the Startup file???

 
SOLVED
Go to solution
praveen..
Super Advisor

which is the Startup file???

Hi,
I need to make the entries in startup file of RHEL AS4 for two commands,

so please let me know in which file, i need to make the entries?

i have done:

#cd /home/praveen
#vi praveen_start.sh
cd /opt/cpu_mem
./alert.sh
:wq!
#chmod 777 praveen_start.sh


#cd /etc/rc5.d
#ln -s /home/praveen/praveen_start.sh praveen
#chmod 777 praveen

then i tried with reboot, but these file could not be run. it didn't work

Please let me know in which file i need to make the entries.

OS Run level is 5, and this entry should be for all the users (local, NIS & root)

thanks
8 REPLIES 8
g33k
Valued Contributor

Re: which is the Startup file???

it depends when you want to run it... probably after you login, I guess.
So it again depends what is your shell.
I recomend bash.

so make a file .bash_login
make it executeble, it's just bash script, which sais what needs to be done just after you login.

It should work also for other shells
.ksh_login
...

if you want to start your script with OS, you need to add this /etc/rc.d with exec rights ofcourse

AjayYadav
New Member

Re: which is the Startup file???

Start up file according to ur profile is.
.bash_profile its a hidden fine at ur home directory..it runs automatically when u login.

Thanks
praveen..
Super Advisor

Re: which is the Startup file???

I dont want to login on the system,

I want this to start with OS.

please suggest
Alexander Chuzhoy
Honored Contributor

Re: which is the Startup file???

did you try your file from command line to see if it works first?
It looks like it's missing the "magic line":

#!/bin/bash

btw, you can replace 2 commands with 1:
/opt/cpu_mem/alert.sh
Steven E. Protter
Exalted Contributor
Solution

Re: which is the Startup file???

Shalom praveen,

#cd /etc/rc5.d
#ln -s /home/praveen/praveen_start.sh praveen
#chmod 777 praveen

The startup location is non-standard, e.g. though it will probably work if the praveen_start.sh script works some future version of SELINUX or security tool may stop it.

The ln -s command will feed the script a start command only if the soft link starts with a captial S, otherwise it will be ignored at run level 5 where its being created.

Suggestion:
#cd /etc/rc5.d
#ln -s /home/praveen/praveen_start.sh S91praveen
#chmod 777 S91praveen

Now at least it will execute at start time.

Better:

#cd /etc/rc5.d
#ln -s /etc/init.d/praveen_start.sh S91praveen
#chmod 777 S91praveen

Relocate the startup script to a standard location.

Last, The script should be able to accept a K (stop) link and able to be shut down the same way its started. e.g. where is the shutdown soft link?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Matti_Kurkela
Honored Contributor

Re: which is the Startup file???

You can add your commands to /etc/rc.local.
It will get executed after all other startup actions.

If you want to put something to /etc/rc5.d, you must make the script's name start with either capital "S" (for Start) or with capital K (for Kill). When starting up to runlevel 5, the server runs all scripts in /etc/rc5.d starting with the "S" in POSIX standard alphanumberic sorting order. Each "S" script is run with command line argument "start". So, if your script is named /etc/rc5.d/S99praveen, the system will execute the command:
/etc/rc5.d/S99praveen start

MK
George Liu_4
Trusted Contributor

Re: which is the Startup file???

Normally you should put your stoff in /etc/rc.local
If you want to put in /etc/init.d/, you'd better to write the script following the examples in the directory.
praveen..
Super Advisor

Re: which is the Startup file???

#cd /etc/rc5.d
#ln -s /etc/init.d/praveen_start.sh S91praveen
#chmod 777 S91praveen


Thanks