背景:远程使用ssh进行机器学习训练的时候程序经常会因为ssh断开链接,程序训练中断。体验机器不佳

安装

  1. sudo apt install screen

简单使用

新建一个train的窗口,并进行一系列操作

  1. screen -S train
  2. cd tmp
  1. screen -r train

命令行提示使用方法

  1. Options:
  2. -4 Resolve hostnames only to IPv4 addresses.
  3. -6 Resolve hostnames only to IPv6 addresses.
  4. -a Force all capabilities into each window's termcap.
  5. -A -[r|R] Adapt all windows to the new display width & height.
  6. -c file Read configuration file instead of '.screenrc'.
  7. -d (-r) Detach the elsewhere running screen (and reattach here).
  8. -dmS name Start as daemon: Screen session in detached mode.
  9. -D (-r) Detach and logout remote (and reattach here).
  10. -D -RR Do whatever is needed to get a screen session.
  11. -e xy Change command characters.
  12. -f Flow control on, -fn = off, -fa = auto.
  13. -h lines Set the size of the scrollback history buffer.
  14. -i Interrupt output sooner when flow control is on.
  15. -l Login mode on (update /var/run/utmp), -ln = off.
  16. -ls [match] or
  17. -list Do nothing, just list our SockDir [on possible matches].
  18. -L Turn on output logging.
  19. -Logfile file Set logfile name.
  20. -m ignore $STY variable, do create a new screen session.
  21. -O Choose optimal output rather than exact vt100 emulation.
  22. -p window Preselect the named window if it exists.
  23. -q Quiet startup. Exits with non-zero return code if unsuccessful.
  24. -Q Commands will send the response to the stdout of the querying process.
  25. -r [session] Reattach to a detached screen process.
  26. -R Reattach if possible, otherwise start a new session.
  27. -s shell Shell to execute rather than $SHELL.
  28. -S sockname Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
  29. -t title Set title. (window's name).
  30. -T term Use term as $TERM for windows, rather than "screen".
  31. -U Tell screen to use UTF-8 encoding.
  32. -v Print "Screen version 4.08.00 (GNU) 05-Feb-20".
  33. -wipe [match] Do nothing, just clean up SockDir [on possible matches].
  34. -x Attach to a not detached screen. (Multi display mode).
  35. -X Execute <cmd> as a screen command in the specified session.