notaloafer
November 4th, 2007, 02:56 PM
Right now I have a program that needs to be run at startup as a daemon process so I don't have to run it in a gnome terminal. Right now the commands to start it are:
su - jbls
(enterpasswords)
cd Desktop/JBLS
java -jar JBLS.jar
This program runs in a terminal text-only window. However I don't like running it on my gnome desktop.
I asked someone on MSN how to create a BASH script to auto-run at startup and he said the following:
Eric: it runs in terminal
Eric: is it easy to daemon-tize it so it auto runs when i start up my server
Tex: hmm
Eric: and so i dont have to run it in gnome? (i usually turn gnome off when im not using it)
Tex: you *might* be able to do that with a script
Tex: does the java app display something graphical?
Eric: nope
Eric: just runs text-base in terminal
Tex: hmm... then you could just make a bash script that contains the startup commands, then put your bash script in /etc/rc.local so that it's run at boot
Tex: that'd be easiest
Eric: hm
Eric: i found /etc/rc.local and opened it
Eric: and theres nothing in it
Eric: how do i go about making a bash script?
Tex: bash scripts are easy, and they look like this:
Tex: #!/bin/bash
cd /somedirectory
./somescript
Eric: ooh ok
Tex: just put the commands you usually run within that script
Tex: then make it executable:
Tex: chmod +x yourbashscript.sh
Tex: then put this in /etc/rc.local
Tex: /bin/bash /path/to/your/bashscript.sh
Eric: ah i see
Tex: good to go
Eric: thanks
Tex: well, if the java app hangs, there is a possibility that your bootup could hang :-/
I would do it myself but I have no idea how to make a BASH script or where to start with it... I also don't want to risk making my server un-bootable by a mis-configuration.
Thanks!
-Eric
su - jbls
(enterpasswords)
cd Desktop/JBLS
java -jar JBLS.jar
This program runs in a terminal text-only window. However I don't like running it on my gnome desktop.
I asked someone on MSN how to create a BASH script to auto-run at startup and he said the following:
Eric: it runs in terminal
Eric: is it easy to daemon-tize it so it auto runs when i start up my server
Tex: hmm
Eric: and so i dont have to run it in gnome? (i usually turn gnome off when im not using it)
Tex: you *might* be able to do that with a script
Tex: does the java app display something graphical?
Eric: nope
Eric: just runs text-base in terminal
Tex: hmm... then you could just make a bash script that contains the startup commands, then put your bash script in /etc/rc.local so that it's run at boot
Tex: that'd be easiest
Eric: hm
Eric: i found /etc/rc.local and opened it
Eric: and theres nothing in it
Eric: how do i go about making a bash script?
Tex: bash scripts are easy, and they look like this:
Tex: #!/bin/bash
cd /somedirectory
./somescript
Eric: ooh ok
Tex: just put the commands you usually run within that script
Tex: then make it executable:
Tex: chmod +x yourbashscript.sh
Tex: then put this in /etc/rc.local
Tex: /bin/bash /path/to/your/bashscript.sh
Eric: ah i see
Tex: good to go
Eric: thanks
Tex: well, if the java app hangs, there is a possibility that your bootup could hang :-/
I would do it myself but I have no idea how to make a BASH script or where to start with it... I also don't want to risk making my server un-bootable by a mis-configuration.
Thanks!
-Eric