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:
...
root 14552 0.0 0.2 2476 1092 pts/0 S 22:46 0:00 su -
root 14553 0.0 0.5 3644 2592 pts/0 S 22:46 0:00 -bash
root 14758 0.0 0.2 2644 1312 ? Ss 22:59 0:00 SCREEN -d -m top
root 14759 0.0 0.2 1972 1028 pts/1 Ss+ 22:59 0:00 top
root 14793 0.0 0.1 2548 824 pts/0 R+ 23:01 0:00 ps aux
Now you can logout from your system but
'top' will still be runnind.
Notice that it runs on an another terminal (do you see pts/0 and pts/1?)!!!
Also look at
'pstree' command output:
Code:
init─┬
...
├─screen───top
├─sshd───sshd───sshd───bash───su───bash───pstree
...
What do you think of it?
Now login again and do:
Code:
[root@squirrel ~]# screen -R
Then press 'q' and exit this virtual terminal with 'exit' - you will return into your normal shell now.
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.