bash script help - "screen"
Hi there,
Ive written this bash function: Code:
function s { s foo.txt to edit my text. But, if I close the terminal I started the editor from it closes. I heard from somewhere that "screen" is the command to use to detach the process from the terminal but I cant get it working with my script. Can anyone help? Thanks H |
try :
s foo.txt & |
Yes, that works..... but why?
I'd backgrounded the process in the script? So can I include that second & in my script? Thanks h |
the "&" sign tell the process to run in the background
Code:
Run a command in the background |
Sometimes if your programm is very interactive :) and do not want to work in background
you may use 'screen' command. Well... Every programm running on your system has a state. You can see it in 8'th column in 'ps aux' command. Running programm has state 'S' or 'R'. When you terminate programm by pressing 'Ctrl+z' or running it with '&' some of them go into 'T' state. But there is a way to make programm work even if you logout from system. Try to do like this: Code:
... Notice that it runs on an another terminal (do you see pts/0 and pts/1?)!!! Also look at 'pstree' command output: Code:
init─┬ Now login again and do: Code:
[root@squirrel ~]# screen -R What is this for? I often use it in my normal work: just work in screen's virtual terminal, then deattach from it and exit shell with leaving my prog working... Sometimes use in scripts. |
All times are GMT -5. The time now is 02:38 PM. |