Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 21812  / 2 Years ago, tue, september 20, 2022, 7:59:18

I am new to shell scripting. I am writing a startup script that takes an argument and launches a process based on the argument value.



Example : I want to launch my groovyConsole located inside some directory using the starter script like this.



sh Starter.sh groovy 


Inside the script this is the logic



if [ $1 = "groovy" ] 
then
cd Works/Groovy/groovy-1.8.6/bin
./groovyConsole
fi


This does start the process but I see that this process is bind with the terminal window. If I close the terminal window the process is being killed (obviously). So I want to know if there is a way that running the above command will execute the script and start the process but close the terminal window?


More From » scripts

 Answers
3

You can detach it from your current process with nohup and &




if [ $1 = "groovy" ]
then
cd Works/Groovy/groovy-1.8.6/bin
nohup ./groovyConsole &
fi


This would leave the command groovyConsole running until you kill it.
This does not close the terminal window though buy you do that like this ...



sh Starter.sh groovy && exit

[#38654] Thursday, September 22, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
variark

Total Points: 82
Total Questions: 114
Total Answers: 122

Location: Sweden
Member since Mon, May 8, 2023
1 Year ago
variark questions
Wed, Nov 3, 21, 13:30, 3 Years ago
Sun, Jan 8, 23, 16:05, 1 Year ago
Thu, Dec 15, 22, 02:10, 1 Year ago
Sun, Jun 26, 22, 12:20, 2 Years ago
Tue, Dec 14, 21, 15:40, 2 Years ago
;