首页Linux文章详情

Linux screen命令中文乱码解决方法

By lakeui / Jan 1, 2021 阅读 0 评论 0 发表于 Linux 字数:2028 阅读时间:21秒

screen中文乱码

摘要:在开发中,我们会经常遇到处理数据的需求,因为数据量比较大,执行时间比较长,一般有2种方法处理,一种是利用队列后台自动执行,一种是开发好脚本,需要的时候去执行,这里screen命令就可以帮助我们处理了

screen命令安装

  1. #centos
  2. yum install screen
  3. #ubuntu
  4. apt install screen

screen命令使用

一般情况下我们使用如下命令创建会话:

  1. #创建
  2. screen -S newsession
  3. #查看
  4. screen -ls
  5. #进入
  6. screen -r newsession

通过这样方式创建的会话,中文都会乱码,通过查阅资料可以通过以下方法解决:

  1. #创建utf8编码模式的新会话
  2. screen -U -S newsession
  3. #切换会话(utf8编码查看)
  4. screen -U -r new_screen_test

已经完成,是不是有点小惊喜了!

扩展

  1. #查看
  2. root@web1:~# screen -ls
  3. There is a screen on:
  4. 13781.refreshPayData (01/20/21 19:07:22) (Detached)
  5. 1 Socket in /var/run/screen/S-root.
  6. #临时退出会话
  7. Ctrl+a+d
  8. #删除screen
  9. screen -d refreshPayData
  10. kill -9 13781
  11. screen -wipe

当然以上只是常用命令,如果想了解screen的所有命令可以通过:

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

手机扫码阅读,舒服~

⌘ + Return 发表
最新 最早 全部评论0 条评论