Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run xterm -e without terminating

I want to run xterm -e file.sh without terminating.

In the file, I'm sending commands to the background and when the script is done, they are still not finished.

What I'm doing currently is:

(cd /myfolder; /xterm -ls -geometry 115x65 -sb -sl 1000) 

and then after the window pops up

sh file.sh
exit

What I want to do is something like:

(cd /myfolder; /xterm -ls -geometry 115x65 -sb -sl 1000 -e sh file.sh)

without terminating and wait until the commands in the background finish.

Anyone know how to do that?

like image 564
jarhead Avatar asked Jun 01 '12 06:06

jarhead


People also ask

Which command keep processes running even after exiting the shell?

One of them is to use the disown command. It tells your shell to refrain from sending a HUP (hangup) signal to the process when you log off. So, the process continues running. This can be very handy whenever you start a process, and then for some reason you can't stay logged in and wait until it finishes.

Can I close terminal after Nohup?

Using 'nohup' With Your Command Nohup will separate the process from the terminal. Because of the disconnect, it will not receive SIGHUP, which is why it is named nohup. If you close the terminal, the process will keep running until you close it.


2 Answers

Use hold option:

xterm -hold -e file.sh

-hold Turn on the hold resource, i.e., xterm will not immediately destroy its window when the shell command completes. It will wait until you use the window manager to destroy/kill the window, or if you use the menu entries that send a signal, e.g., HUP or KILL.

like image 86
imwilsonxu Avatar answered Sep 30 '22 02:09

imwilsonxu


I tried -hold, and it leaves xterm in an unresponsive state that requires closing through non-standard means (the window manager, a kill command). If you would rather have an open shell from which you can exit, try adding that shell to the end of your command:

xterm -e "cd /etc; bash"

I came across the answer on Super User.

like image 40
Gid Avatar answered Sep 30 '22 02:09

Gid