helpJavaGuru
asked on
linux startup script
I have a java daemon program that need to add to linux startup script so everytime when the machine start it will execute the java program.
Can anyone tell me how to do so as I am not familiar with linux.
the command I need to execute is Java -classpath /var/test programA
I tried to cron but I am not able to get it working so I wrote a daemon and hope it can be add to the startup script.
Thanks.
Can anyone tell me how to do so as I am not familiar with linux.
the command I need to execute is Java -classpath /var/test programA
I tried to cron but I am not able to get it working so I wrote a daemon and hope it can be add to the startup script.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Owensleftfoot,
I agreed. I am looking into .bashrc file. is this the right file to add? As you know, there are so many startup script and UNIX is .rc I believe. It's so confusing. the problem is I need to get a C program running and I tried to cron it but the problem is if I cron, I need to definite the classes as cron does not pick up env setup. Thus, I add a timer but I need to make sure when the machine reboot, the program still run. I do not want to manually start the program for every reboot.
So the question is if I should add it in the .bashrc file? is this where most people use as startup script?
I agreed. I am looking into .bashrc file. is this the right file to add? As you know, there are so many startup script and UNIX is .rc I believe. It's so confusing. the problem is I need to get a C program running and I tried to cron it but the problem is if I cron, I need to definite the classes as cron does not pick up env setup. Thus, I add a timer but I need to make sure when the machine reboot, the program still run. I do not want to manually start the program for every reboot.
So the question is if I should add it in the .bashrc file? is this where most people use as startup script?
.bashrc is a bad option if you only want the command run once - every bash shell which opens will run .bashrc
Add the complete path to your program as the last line in /etc/rc.d/rc.local - rc.local is a script run at every boot after all the other rc files are run.
Add the complete path to your program as the last line in /etc/rc.d/rc.local - rc.local is a script run at every boot after all the other rc files are run.
.bashrc may not be a good idea ,
.bashrc is run whenever a new shell is spawned , so you may end up with multiple instances of your program ( which may or may not be desired)
~/.bash_profile should be okay but i would still go for what is suggested by Owensleftfoot
/abhijit/
.bashrc is run whenever a new shell is spawned , so you may end up with multiple instances of your program ( which may or may not be desired)
~/.bash_profile should be okay but i would still go for what is suggested by Owensleftfoot
/abhijit/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys. I spilt the points because you guys contributed to the solutions.
I actually was able to write a wrapper to get it working but I do need to know this as some point in time I will need it again.
Thanks for your help.
I actually was able to write a wrapper to get it working but I do need to know this as some point in time I will need it again.
Thanks for your help.
for example in gentoo you can put it into any of
rc0.d/ rc2.d/ rc3.d/ rc5.d/
where the numerals denote the run level.
you need to check up with the individual distros to find the exact directory location
hope it helped
/abhijit/