Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a startup script that i put in /etc/init.d
i have a symbolic link in r3.d
When i reboot the system, the process generated by the script are not running.
i can execute the script at /etc/init.d
Pls kindly assist
What is the default runlevel for your system? Look in /etc/inittab for the line like "id:5:initdefault:". Mine here is set to boot to runlevel 5. If it isn't 3, then you might not be running your script. In my case, scripts on rc5.d will be run, but not rc3.d.
Check the man page for chkconfig to see who you can use it to control the execution of scripts in /etc/init.d.
Read the manpages for chkconfig (if your system has it) and insserv. Also look for a skeleton script. The comments at the beginning of startup scripts are important and contain info on which runlevels the stript should start in and which services need to be running before the script.
The script needs a line at toward the start, that tells chkconfig how the script should be started - i.e. in which runlevels, and at what priority it should be started and stopped. This can look like this:-
Code:
# chkconfig: 2345 99 00
From the man-page for chkconfig:-
Code:
RUNLEVEL FILES
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script. The
first line tells chkconfig what runlevels the service should be started in by default, as well as the start and stop
priority levels. If the service should not, by default, be started in any runlevels, a - should be used in place of the
runlevels list. The second line contains a description for the service, and may be extended across multiple lines with
backslash continuation.
For example, random.init has these three lines:
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
# higher quality random number generation.
This says that the random script should be started in levels 2, 3, 4, and 5, that its start priority should be 20, and
that its stop priority should be 80. You should be able to figure out what the description says; the \ causes the line
to be continued. The extra space in front of the line is ignored.
I suggest you consider when you want the script to start and stop, add the appropriate line to it, and run chkconfig again to ensure it will run at boot time.
Now, assuming that the script is starting and stopping correctly, and it still isn't working, add some debugging statements (e.g. "echo I'm about to start the process >> /var/log/script.log", and "echo "The process should now be started >> /var/log/script.log") to the script so that you can see what it is doing when it is called during startup and shutdown.
I have found what's the issue for the startup script. I have a variable in my .bashrc (i'm using root) which is $RMDS_SW= /software/rmds
when i startup the system, it doesnt seems to export this variable and therefore my startup script couldnt navigate to the correct path to run the command.
How do i set this in the system environment? Thanks.
BTW, what's the different in putting under .bashrc and .bash_profile?
appreciate any help
if [ -z "$RMDS_SW" ]; then
RMDS_SW=/software/rmds
fi
This will check to see if the variable RMDS_SW is a null string or not, and if it is, will assign it a value. You script is then always sure of having a value for $RMDS_SW.
i guess i found the issue. It will run the script first before loading the root's .bashrc profile. Therefore what i did was do a source of that profile in the script. Is that the right way to do it?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.