由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - 如何重新控制一个进程
相关主题
screen是干啥的有没有什么分割桌面或屏幕的工具类似于grid
screen问题,不同用户之间如何reattatch?screen如何使用大于10的tab?
Screen用ctrl-a S split屏幕以后的问题screen能竖着分屏幕吗?
linux下面的剪贴板太乱了怎么控制两个嵌套的screen?
terminal窗口不能用Ctrl+V来粘贴?screen can be split vertical now`
如何在xterm里重定义键盘按键?screen下的滚屏问题
how to avoid hang when using screen+Vim?耗时很长的一个command
有没有啥screen的apache插件或者web插件求助: Error: Your DISPLAY environmental variable has not been set.
相关话题的讨论汇总
话题: ctrl话题: screen话题: xpra话题: session话题: command
进入Linux版参与讨论
1 (共1页)
c******g
发帖数: 63
1
小弟远程控制一台Linux终端跑Matlab程序,网络断了,重连上时,可以看到进程列表
里还在跑着
matlab(估计程序也一直在run),但是光有PID,却不知道怎么重新控制这个进程。难
道只能Kill掉
这个MATLAB进程重新跑一编程序吗?多谢众位大侠指点迷津!
N****w
发帖数: 21578
2
use screen, vnc, NX

【在 c******g 的大作中提到】
: 小弟远程控制一台Linux终端跑Matlab程序,网络断了,重连上时,可以看到进程列表
: 里还在跑着
: matlab(估计程序也一直在run),但是光有PID,却不知道怎么重新控制这个进程。难
: 道只能Kill掉
: 这个MATLAB进程重新跑一编程序吗?多谢众位大侠指点迷津!

c******g
发帖数: 63
3
How to do it in a terminal? Thanks!
N****w
发帖数: 21578
4
运行 screen 了再运行 matlab

【在 c******g 的大作中提到】
: How to do it in a terminal? Thanks!
l*******G
发帖数: 1191
5
Screen help:
http://www.rackaid.com/resources/linux-screen-tutorial-and-how-
http://news.softpedia.com/news/GNU-Screen-Tutorial-44274.shtml
GNU Screen is a free terminal multiplexer that allows console users to run
any number of text-based applications, interactive command shells, curses-
based applications, text editors etc, within a single terminal. Similar to
VNC, screen enables you to start applications from one computer, reconnect
from another computer and continue using the same application without having
to restart it. If you are one of those Linux users that keep several
console sessions opened at all times, you should really give screen a try.
Screen also has the ability to keep the application running even after you
have accidentally closed the terminal, logged out or even had a connection
drop and allows you to later reattach to it, resuming your work right from
where you left it.
Another powerful screen feature is its session sharing ability. Screen
enables several users to connect to the same session at once, allowing
collaboration between them by sharing the same console. Most likely, this
feature is mostly being used for teaching and explaining purposes this way:
the 'teacher' starts the screen and several 'students' will attach to that
session, watching the 'teacher's commands and actions. The problem with this
feature it that screen's documentation doesn't offer an obvious how-to use
it. But I'll try to explain it later on. First, with the basic commands.
Creating and switching between sessions
1 start a fresh screen session:
#screen
You will be probably greeted by a welcome screen showing some information
explaining screen's license, where to report bugs and so on. Press the space
bar to bypass this screen. Optionally, you can disable it permanently by
adding the following line to your $HOME/.screenrc file:
startup_message off
Every new created screen window is identified by an unique number. The first
window (the one you're actually using) is numbered as 0, while future
windows will be labeled as 1, 2, 3 etc. In this window, type a simple
command (w or uptime)
uptime
so you can recognize it later. Keep in mind that screen's default command
character is Ctrl+a (press the Ctrl key, hold it and press a, then release
them both). Moreover, the command (letter) entered after Ctrl+a is case
sensitive, so for example Ctrl+a n is a different command from Ctrl+a N.
2. Create new window within screen session
Ctrl+a c
3. Switch between windows within screen session
Ctrl+a n
Ctrl+a 0~9
4. List all windows in a screen session
Ctrl+a Shift+'
Ctrl+a w
5. Rename a window
Ctrl+a A
6. Kill non-responding programs
Ctrl+a K
7. Detaching from a screen session
Ctrl+a d
8. Reattach to existing session
screen -r
screen -ls
screen -x
# screen -r
There are several suitable screens on:
4870.pts-4.localhost (Detached)
4638.pts-1.localhost (Detached)
screen -r 4870.pts-4.localhost
screen -x 4870.pts-4.localhost
9. Sharing a screen session
To share a terminal with one or more users, you have to:
1). Set the screen binary setuid bit root: (THIS IS TO ELIMINATE A
POSSIBLE SECURITY HOLE)
sudo chmod +s /usr/bin/screen.real
sudo chmod +s /usr/bin/screen
sudo chmod 0755 /var/run/screen
2). Login and start a screen session and give it a name:
screen -S sessionName
3). Enable screen's multi-user access function by pressing Ctrl+a then :
multiuser on
Ctrl+a
:multiuser on
4). Grant permissions to the second user by pressing Ctrl+a : acladd
username, where username is the Unix user for the second user.
Ctrl+a
:acladd username
The teacher can also make the student's session read-only. To do
this, use the aclchg screen command to remove write access for the student:
Ctrl+a
:aclchg student -w "#"
The student can then only observe the teacher's actions.
Otherwise, the teacher will have to let the student work on the honor system.
5). Ask the second user to connect to your computer through SSH and type
screen -x youusername/sessionName
where yourusername is the username who started the screen in
step 2)
6). Send messages to all sharing users:
There is also an message feature in multiuser screen: Ctrl-a :wall
10. Scroll back, Copying and Pasting
enable copy mode
Ctrl+a [
then can use arrow keys, page up/dn, home/end
Select text for copying:
Pressing Enter will start marking text for copying.
Pressing Enter again will copy the selected text into the
clipboard.
Now, to paste that text, press Ctrl+a ]
Ctrl+a ]
Ctrl-a esc (copy) Enter copy/scrollback mode.
Ctrl-a ] (paste .) Write the contents of the paste
buffer to the
stdin queue of the current window.
Ctrl-a {
Ctrl-a } (history) Copy and paste a previous (command)
line.
Ctrl-a > (writebuf) Write paste buffer to a file.
C-a < (readbuf) Reads the screen-exchange file into the
paste
buffer.
11. Log outputs to a file
Ctrl-a h (hardcopy) Write a hardcopy of the current window
to the
file "hardcopy.n".
Ctrl-a H (log) Begins/ends logging of the current
window to
the file "screenlog.n".
Enable logging/Disable logging
Ctrl+a H
log file will be saved as $HOME/screenlog.0 etc .
or
Ctrl-a :
logfile filename.txt
Ctrl-a :
log
To make the logfile name as filename.txt and start the log of stop
logging using the log command
How to remove control characters in the log.
exit the screen that's being logged, ctrl-a d
then follow exact steps here
screen
cd /path/to/screenlog.n directory/
wc -l filename.txt
screen -X scrollback nnnn #nnnn is the number of lines found
from your wc command + 5000
cat screenlog.n
screen -X hardcopy -h filename.txt.cleaned
exit
Finally you have the cleaned version in filename.txt.cleaned
12. Splitting the screen window in half horizontally
Ctrl+a S
To move to the bottom half, press Ctrl+a, then the TAB key.
Ctrl+a TAB
To return to full size screen, switch to the half you want it to remain
and press Ctrl+a Q.
Ctrl+a Q
13. Exiting the screen
exit
14. Advanced topic: screen with xwindows
https://help.ubuntu.com/community/Xpra
on remote machine, install xpra:
sudo apt-get install xpra
ssh on to the on remote machine, start an x program using xpra:
xpra start :7
screen

env DISPLAY=:7 x-appname & #Here x-app could be firefox
or xclock or anthing else, such as xlogo
detach from the screen, quit the ssh session.
To attach:
ssh to remote machine again.
screen -ls
screen -x session-name
xpra attach :7 &

detach the screen as usual
xpra attach ssh:frodo:7
Use ssh to attach to the xpra server that is running on machine
frodo and using display :7. Any apps running on that server will appear on
your local screen.
xpra start :7 && DISPLAY=:7 screen
Start an xpra server and a screen session. If any of the
applications inside screen attempt to use X, they will be directed to the
xpra server.
xpra stop :7
Stop the xpra server on display number :7.
1 (共1页)
进入Linux版参与讨论
相关主题
求助: Error: Your DISPLAY environmental variable has not been set.terminal窗口不能用Ctrl+V来粘贴?
FreeRunner is DEAD如何在xterm里重定义键盘按键?
不容易呀,一年没关机了how to avoid hang when using screen+Vim?
The size of your penis is...有没有啥screen的apache插件或者web插件
screen是干啥的有没有什么分割桌面或屏幕的工具类似于grid
screen问题,不同用户之间如何reattatch?screen如何使用大于10的tab?
Screen用ctrl-a S split屏幕以后的问题screen能竖着分屏幕吗?
linux下面的剪贴板太乱了怎么控制两个嵌套的screen?
相关话题的讨论汇总
话题: ctrl话题: screen话题: xpra话题: session话题: command