首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >linux新开screen后台跑脚本

linux新开screen后台跑脚本

原创
作者头像
用户1685462
修改于 2021-08-13 17:38:47
修改于 2021-08-13 17:38:47
2.8K0
举报
文章被收录于专栏:网站教程网站教程

1.新开一个screen :

[root@localhost ~]# screen

2.进入screen执行脚本:

[root@localhost ~]# 省略...

3.脚本执行过程中可以关闭你的终端连接:

[root@localhost ~]# exit

4.查看脚本是否还在运行(或窗口状态):

[root@localhost ~]# screen -ls There is a screen on: 23790.pts-1.localhost  (Attached)  //这说明本地窗口连接没有关闭 1 Socket in /var/run/screen/S-xinfang.

[root@localhost ~]#

[root@localhost ~]# screen -ls There is a screen on: 23790.pts-1.localhost  (Detached)  //这说明本地窗口连接已经关闭,但screen并未关闭 1 Socket in /var/run/screen/S-xinfang.

[root@localhost ~]#

5.查看主机cpu负载指数:

[root@localhost ~]# top

load average: 0.43

6.客户端切回screen窗口界面查看脚本执行状况:

[root@localhost ~]# screen -x 23790

7.推出screen:

[root@localhost ~]# exit

[screen isterminating]  //标识该screen已经关闭

8.查看screen窗口是否关闭:

[root@localhost ~]# screen -ls No Sockets found in/var/run/screen/S-xinfang.  // 标识已经没有sockets 窗口连接,screen已经成功退出

[root@localhost ~]#

9.附带screen的相关命令:

[root@localhost ~]# screen -help Use: screen [-opts] [cmd [args]] or: screen -r [host.tty]

Options: -a  Force all capabilities into each window's termcap. -A-[r|R]  Adapt all windows to the new display width &height. -cfile  Read configuration file instead of '.screenrc'. -d(-r)  Detach the elsewhere running screen (and reattach here). -dmSname  Start as daemon: Screen session in detached mode. -D(-r)  Detach and logout remote (and reattach here). -D-RR  Do whatever is needed to get a screen session. -exy  Change command characters. -f  Flow control on, -fn = off, -fa = auto. -hlines  Set the size of the scrollback history buffer. -i  Interrupt output sooner when flow control is on. -l  Login mode on (update /var/run/utmp), -ln = off. -list  or -ls. Do nothing, just list our SockDir. -L  Turn on output logging. -m  ignore $STY variable, do create a new screen session. -O  Choose optimal output rather than exact vt100 emulation. -pwindow  Preselect the named window if it exists. -q  Quiet startup. Exits with non-zero return code ifunsuccessful. -r  Reattach to a detached screen process. -R  Reattach if possible, otherwise start a new session. -sshell  Shell to execute rather than $SHELL. -S sockname  Name this session.sockname instead of ... -ttitle  Set title. (window's name). -Tterm  Use term as $TERM for windows, rather than "screen". -U  Tell screen to use UTF-8 encoding. -v  Print "Screen version 4.00.03 (FAU) 23-Oct-06". -wipe  Do nothing, just clean up SockDir. -x  Attach to a not detached screen. (Multi display mode). -X  Execute as a screen command in the specified session. [root@localhost ~]#

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档