linux之screen运行脚本

~小疯子~ ~小疯子~     2022-12-14     630

关键词:

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 ~]#

⭐️《linux系列》⭐️linux命令之screen命令(代码片段)

Screen命令❤️前言❤️⭐️Screen命令⭐️1、安装Screen命令2、开启2个窗口3、A窗口寻求B帮助4、退出控制❄️写在最后❄️❤️前言❤️如果你使用Linux遇到一个问题,想要邀请别人来进行远程控制解决,我们一般可以通... 查看详情

⭐️《linux系列》⭐️linux命令之screen命令(代码片段)

Screen命令❤️前言❤️⭐️Screen命令⭐️1、安装Screen命令2、开启2个窗口3、A窗口寻求B帮助4、退出控制❄️写在最后❄️❤️前言❤️如果你使用Linux遇到一个问题,想要邀请别人来进行远程控制解决,我们一般可以通... 查看详情

linux使用screen后台运行程序(代码片段)

LInux使用Screen后台运行程序yuminstallscreen如何快速停止所有screenscreenscreen。screen-Stest_bot#创建一个名为test_bot的新screen并进入screen-ls#查看当前运行的kill-9pid1pid2#杀死对应的进程screen-wipe#remove已经停止的screenctrl+a+d#返回进入scree... 查看详情

linux基础之bash脚本编程进阶篇-选择执行语句(if,case)

...写解释器路径/bin/bash由于bash属于脚本语言,脚本语言的运行方式解释运行:源代码-->运行时启动解释器,由解释器边解释边运行Linux中的脚本解释器有:zsh,csh,bash,tsh众多shell,不过bash最常用。第一行写完之后,就可以直... 查看详情

linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本

...好的软件包,在其它linux的平台上,可能并不能正常安装运行,在此情况下,源码包编译安装出现了。 查看详情

您如何从屏幕会话中编写 gnu screen 脚本以打开新窗口并在其中运行命令?

】您如何从屏幕会话中编写gnuscreen脚本以打开新窗口并在其中运行命令?【英文标题】:howdoyouscriptgnuscreenfromwithinascreensessiontoopennewwindowsandruncommandsinthem?【发布时间】:2010-01-2816:55:16【问题描述】:在屏幕会话中,我想运行一个... 查看详情

linux系统shell脚本之监控httpd服务(代码片段)

...本要求1.要求监控服务器的httpd服务是否启动,并且脚本运行后,输出检测结果2.无论检测结果如何,脚本执行三次,并输出结果3.当检测到服务失败是,重启服务,并提示二、脚本内容[root@192scripts]#cathttpd.sh#!/bin/bash##################... 查看详情

linux之shell脚本编程(代码片段)

...门的编译过程,把程序编译成为机器语言文件,运行时不需要重新翻译,直接使用编译结果就行。程序执行效率高,依赖编译器࿰ 查看详情

linux之sell脚本实战centos最小化安装环境配置脚本(代码片段)

...置~/.vimrc2.查看注释模板效果四、编写init.sh脚本五、测试运行脚本六、实践总结一、脚本要求1.系统版本为centos7,最小化安装;2.要求安装基本工具:vim/tree/git/wget/netstat/3.配 查看详情

linux终端命令神器--screen命令

参考技术Ascreen的功能大体有三个:会话恢复:只要Screen本身没有终止,在其内部运行的会话都可以恢复。多窗口:在Screen环境下,所有的会话都独立的运行,并拥有各自的编号、输入、输出和窗口缓存。会话共享:Screen可以让... 查看详情

xshell设置运行自动化脚本(代码片段)

...js脚本*//*主函数*/functionMain()/*发送cd改变到当前目录*/xsh.Screen.Send("cd~/projects/cyp-assout/logs/ 查看详情

linux下shell脚本中信号捕获和函数练习脚本之ping一个网段

...信号,顺便练习一下函数的使用,还有就是终止一个正在运行的程序后,该程序打开的文件的后续处理问题等等!脚本功能: ping一个网段内的IP,检测哪些IP在线,哪些IP不在线练习的命令:1、mktemp 用法:#mktemp1117.www.qix... 查看详情

linux下shell脚本中信号捕获和函数练习脚本之ping一个网段

...信号,顺便练习一下函数的使用,还有就是终止一个正在运行的程序后,该程序打开的文件的后续处理问题等等!脚本功能: ping一个网段内的IP,检测哪些IP在线,哪些IP不在线练习的命令:1、mktemp  用法:#mktemp/Path/... 查看详情

linux系统下shell脚本实战之mariadb创建数据库和表(代码片段)

...7.测试远程登录三、编写shell脚本四、执行脚本五、检查运行结果一、脚本要求向mariadb数据库创建测试数据库和表二、环境准备1.配置yum仓库#vim/etc/yum.repos.d/m 查看详情

linux如何后台运行

...,表示在前台的Console中可以执行其他任务。 参考技术B用screen命令简单地说下运行screen然后运行你想要运行的程序按ctrl+a,d暂时断开screen--screen-ls查看刚才程序进程号screen-r进程号重新回来C-a? 显示所有键绑定信息C-aw 显示所有窗... 查看详情

断电不断网——linux的screen

 title:断电不断网——Linux的screenauthor:青南date:2015-01-0120:20:23categories:[Linux]tags:[linux,screen,session]---在使用AWS亚马逊云搭建Gmail转发服务(二)中,我们最后运行了邮件转发程序。本以为程序就可以正常工作了,于是我关... 查看详情

shell脚本之笔记一

...系统这个脚本需要什么解释器来执行,即使用哪一种Shell运行shell (chmod+xfile 加上执行权限,否则会提示无执行权限)    一定要写成 ./test.sh,而不是 test.sh运行其它二进制的程序也一样,直接写test.sh    li... 查看详情

linux笔记:screen(代码片段)

1screen介绍        Linuxscreen命令用于多重视窗管理程序。此处所谓的视窗,是指一个全屏幕的文字模式画面。        用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。        ... 查看详情