zoukankan      html  css  js  c++  java
  • linux中screen用法

    screen实现一个类似windows中最小化运行的效果,可以在后台运行,之后想用时再调到前台。其实一直想学学怎么用的,但一直没什么契机。

    其实常用的命令就几个。(注意参数大小写有区别)

    screen -S yourname -> 新建一个叫yourname的session
    screen -ls -> 列出当前所有的session
    screen -r yourname -> 回到yourname这个session
    screen -d yourname -> 远程detach某个session
    screen -d -r yourname -> 结束当前session并回到yourname这个session

    在screen中使用快捷键ctrl+a+d,退出当前screen并在后台运行,使用ls命令可以看到处于detached状态

    在screen中输入exit,退出并删除当前screen

    在使用过程中发现了几点问题。

    1、可以使用同名的screen,但是会分配不同的pid,可以ls显示具体的session-id。显示的格式时pid.name

    2、对于显示已经Attached但是又没有在前台使用的screen无法进行连接 ,可以使用

    screen -D  -r <session-id>

    命令。相当于把前一用户踢掉。

    来解析一条比较长的命令,最近折腾泰拉瑞亚服务器找到一条启动命令(https://www.cnblogs.com/roadwide/p/12673229.html

    /usr/bin/screen -dmS terraria /bin/bash -c "/opt/terraria/TerrariaServer.bin.x86_64 -config /opt/terraria/serverconfig.txt"

    -d <作业名称>  将指定的screen作业离线。

    -m  即使目前已在作业中的screen作业,仍强制建立新的screen作业。

    -S <作业名称>  指定screen作业的名称。

    /bin/bash -c 这部分不明白是什么意义。
    bash -c "cmd string"
    -c        If the -c option is present, then commands are read from the first non-option argument command_string.  If there are arguments after the command_string, they are
               assigned to the positional parameters, starting with $0.

    参考文章:

    https://man.linuxde.net/screen

    https://blog.csdn.net/gdali/article/details/72799581

    https://www.jianshu.com/p/198d819d24d1

  • 相关阅读:
    【排序】冒泡排序,C++实现
    【排序】选择排序,C++实现
    【排序】插入排序,C++实现
    【集成学习】 lightgbm原理
    leetcode1310
    leetcode1309
    leetcode1300
    leetcode1302
    leetcode1299
    leetcode1306
  • 原文地址:https://www.cnblogs.com/roadwide/p/12612152.html
Copyright © 2011-2022 走看看