Startup script cant work
Hi,
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. What platform are you using? |
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.
|
Hi,
I have checked the inittab. It has id:3:initdefault: I have similar scripts in another linux server. No specific things in the script but that works.(it's not written by me though) i did a [root@sins476036 etc]# chkconfig --level 3 p2psinit on service p2psinit does not support chkconfig but the msg indicate that i cant use the chkconfig. Any idea guys? |
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 Code:
RUNLEVEL FILES 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. |
Hi,
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 |
Hi any1 can help with the above?
|
Add this near the top of your script in init.d:-
Code:
if [ -z "$RMDS_SW" ]; then |
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?
|
Setting the environment in your script is the key. If using the root user's .bashrc does that for you, then that is fine.
|
All times are GMT -5. The time now is 07:49 AM. |