运行“屏幕”例如:
screen /dev/ttyUSB0 115200
如何偶尔清除屏幕?
运行“屏幕”例如:
screen /dev/ttyUSB0 115200
如何偶尔清除屏幕?
我在家庭服务器上运行 ubuntu 20.04 服务器,并且我有一个自托管的 minecraft 实例,位于 /opt/minecraft/server,由用户 minecraft 拥有。我可以手动激活服务器就好了。但是,我想让服务器在启动时不断运行该进程,但我无法让 systemd 脚本正常工作。我将在下面发布,但这里有一些初步的
这是我验证 minecraft:minecraft 拥有一切:
albert@mfs:/opt/minecraft$ ls -l survival
total 37108
-rw-r--r-- 1 minecraft minecraft 2 Nov 26 01:04 banned-ips.json
-rw-r--r-- 1 minecraft minecraft 2 Nov 26 01:04 banned-players.json
-rw-r--r-- 1 minecraft minecraft 180 Nov 25 23:16 eula.txt
drwxr-xr-x 2 minecraft minecraft 4096 Nov 26 01:04 logs
-rw-r--r-- 1 minecraft minecraft 136 Nov 26 01:04 ops.json
-rw-r--r-- 1 minecraft minecraft 37961464 Nov 25 23:16 server.jar
-rw-r--r-- 1 minecraft minecraft 1073 Nov 26 01:04 server.properties
-rw-r--r-- 1 minecraft minecraft 323 Nov 26 03:30 usercache.json
-rw-r--r-- 1 minecraft minecraft 2 Nov 25 23:16 whitelist.json
drwxr-xr-x 11 minecraft minecraft 4096 Nov 26 04:36 world
启动服务并检查状态后:
albert@mfs:~$ sudo systemctl status minecraft@survival
● [email protected] - Minecraft Server survival
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2020-11-26 21:13:11 UTC; 5s ago
Process: 99802 ExecStart=/bin/sh -c /usr/bin/screen -DmS mc-survival /usr/bin/java -server -Xms512M -Xmx2048M -XX:+UseG1GC -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadi>
Process: 99820 ExecStop=/usr/bin/screen -p 0 -S mc-survival -X eval stuff "say SERVER SHUTTING DOWN. Saving map..."\015 (code=exited, status=1/FAILURE)
Main PID: 99802 (code=exited, status=0/SUCCESS)
检查 journalctl 后
albert@mfs:~$ journalctl -u minecraft@survival
-- Logs begin at Wed 2020-06-03 18:13:36 UTC, end at Thu 2020-11-26 20:59:45 UTC. --
Nov 25 23:18:34 my.freakin.server systemd[1]: Started Minecraft Server: survival.
Nov 25 23:18:34 my.freakin.server screen[78218]: No screen session found.
Nov 25 23:18:34 my.freakin.server systemd[1]: [email protected]: Control process exited, code=exited, status=1/FAILURE
Nov 25 23:18:34 my.freakin.server systemd[1]: [email protected]: Failed with result 'exit-code'.
Nov 25 23:18:34 my.freakin.server systemd[1]: [email protected]: Scheduled restart job, restart counter is at 1.
[and so on, four more times]
我尝试了几个不同的配置文件,并注意到这个问题没有变化(可以确认我一直在重新加载守护进程)。(我应该启用分叉吗?)。这是我当前的 systemd 文件:
albert@mfs:~$ cat /etc/systemd/system/[email protected]
# source: https://github.com/agowa338/MinecraftSystemdUnit/
# License: MIT
[Unit]
Description=Minecraft Server %i
After=network.target
[Service]
WorkingDirectory=/opt/minecraft/%i
PrivateUsers=true
# Users Database is not available for within the unit, only root and minecraft is available, everybody else is nobody
User=minecraft
Group=minecraft
ProtectSystem=full
# Read only mapping of /usr /boot and /etc
ProtectHome=true
# /home, /root and /run/user seem to be empty from within the unit. It is recommended to enable this setting for all long-running services (in particular network-facing ones).
ProtectKernelTunables=true
# /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be read-only within the unit. It is recommended to turn this on for most services.
# Implies MountFlags=slave
ProtectKernelModules=true
# Block module system calls, also /usr/lib/modules. It is recommended to turn this on for most services that do not need special file systems or extra kernel modules to work
# Implies NoNewPrivileges=yes
ProtectControlGroups=true
# It is hence recommended to turn this on for most services.
# Implies MountAPIVFS=yes
# ExecStart=/bin/strace -o /tmp/s -f screen -dm -S me bash -c 'sleep 999'
ExecStart=/bin/sh -c '/usr/bin/screen -DmS mc-%i /usr/bin/java -server -Xms512M -Xmx2048M -XX:+UseG1GC -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar $(ls -v | grep -i "FTBServer.*jar\|minecraft_server.*jar" | head -n 1) nogui'
#ExecReload=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "reload"\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "save-all"\\015'
ExecStop=/usr/bin/screen -p 0 -S mc-%i -X eval 'stuff "stop"\\015'
ExecStop=/bin/sleep 10
Restart=on-failure
RestartSec=60s
[Install]
WantedBy=multi-user.target
#########
# HowTo
#########
#
# Create a directory in /opt/minecraft/XX where XX is a name like 'survival'
# Add minecraft_server.jar into dir with other conf files for minecraft server
#
# Enable/Start systemd service
# systemctl enable minecraft@survival
# systemctl start minecraft@survival
#
# To run multiple servers simply create a new dir structure and enable/start it
# systemctl enable minecraft@creative
# systemctl start minecraft@creative
在 ExecStart 命令的正上方,您可以看到一个带有 strace 的注释掉的命令。我进行了足够的研究以弄清楚如何将其放入,但我几乎无法阅读它。跟踪很长,所以除非有人要求,否则我不会添加它;也就是说,这里是引发某种错误的跟踪的所有结果。
81270 arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc8a212000) = -1 EINVAL (Invalid argument)
81270 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
81270 access("/opt/minecraft/.nethackrc", F_OK) = -1 ENOENT (No such file or directory)
81270 access("/opt/minecraft/.nethackrc", F_OK) = -1 ENOENT (No such file or directory)
81270 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
81270 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
81270 openat(AT_FDCWD, "/etc/shadow", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
81270 openat(AT_FDCWD, "/etc/shadow", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
81271 connect(3, {sa_family=AF_UNIX, sun_path="/run/screen/S-minecraft/81271.me"}, 34) = -1 ENOENT (No such file or directory)
81271 unlink("/run/screen/S-minecraft/81271.me") = -1 ENOENT (No such file or directory)
81271 ioctl(1, TCGETS, 0x7ffc8a210800) = -1 ENOTTY (Inappropriate ioctl for device)
81271 stat("/opt/minecraft/.terminfo", 0x564c0619b900) = -1 ENOENT (No such file or directory)
81271 access("/etc/terminfo/s/screen", R_OK) = -1 ENOENT (No such file or directory)
81271 ioctl(2, TCGETS, 0x7ffc8a210800) = -1 ENOTTY (Inappropriate ioctl for device)
81271 ioctl(2, TCGETS, 0x7ffc8a210790) = -1 ENOTTY (Inappropriate ioctl for device)
81271 openat(AT_FDCWD, "/opt/minecraft/.screenrc", O_RDONLY) = -1 ENOENT (No such file or directory)
81271 stat("bash", 0x7ffc8a2107f0) = -1 ENOENT (No such file or directory)
81271 openat(AT_FDCWD, "/dev/ptmx", O_RDWR) = 4
81271 connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
81271 connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
81271 chown("/dev/pts/1", 995, 5) = -1 EINVAL (Invalid argument)
81272 access("/etc/terminfo/s/screen", R_OK) = -1 ENOENT (No such file or directory)
81272 execve("/usr/local/sbin/bash", ["bash", "-c", "sleep 999"], 0x564c0619ff10 /* 12 vars */) = -1 ENOENT (No such file or directory)
81272 execve("/usr/local/bin/bash", ["bash", "-c", "sleep 999"], 0x564c0619ff10 /* 12 vars */) = -1 ENOENT (No such file or directory)
81272 execve("/usr/sbin/bash", ["bash", "-c", "sleep 999"], 0x564c0619ff10 /* 12 vars */) = -1 ENOENT (No such file or directory)
81272 arch_prctl(0x3001 /* ARCH_??? */, 0x7ffede633760) = -1 EINVAL (Invalid argument)
81272 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
81272 ioctl(-1, TIOCGPGRP, 0x7ffede6335b4) = -1 EBADF (Bad file descriptor)
81272 stat("/usr/local/sbin/bash", 0x7ffede633220) = -1 ENOENT (No such file or directory)
81272 stat("/usr/local/bin/bash", 0x7ffede633220) = -1 ENOENT (No such file or directory)
81272 stat("/usr/sbin/bash", 0x7ffede633220) = -1 ENOENT (No such file or directory)
81272 getpeername(0, 0x7ffede6335b0, [16]) = -1 ENOTSOCK (Socket operation on non-socket)
81272 stat("/usr/local/sbin/sleep", 0x7ffede633110) = -1 ENOENT (No such file or directory)
81272 stat("/usr/local/bin/sleep", 0x7ffede633110) = -1 ENOENT (No such file or directory)
81272 stat("/usr/sbin/sleep", 0x7ffede633110) = -1 ENOENT (No such file or directory)
81272 arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc09151430) = -1 EINVAL (Invalid argument)
81272 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
有人有想法吗?我不清楚屏幕会话问题是什么或如何解决它。非常感谢大家的时间和想法。
我最近从三重启动笔记本电脑(其他是 Windows 10 和 ubuntu 20.04)上卸载了 kali Linux,而不是 grub 2,它在引导过程中显示 Windows 和 ubuntu,我所看到的只是一个 GNU grub,我不知道该怎么做,当我输入'exit'我去windows并且无法进入ubuntu,我怎样才能找回grub 2,请帮助
我正在screen
我的 Ubuntu 服务器上使用该命令运行一组进程。这个想法是理想情况下不应取消该过程或有被错误取消的风险
我发现使用Ctrl+a d是一个非常危险的分离屏幕的热键,因为使用Ctrl+d会终止它。
有没有办法将分离热键更改为其他东西?例如,我可以将Ctrl+更改a d为Ctrl+q吗?
我尝试使用别名,但这不适用于键盘命令。
我是新手,所以如果我使用了错误的术语,我深表歉意。
我正在使用 Linux 并使用 ssh 功能连接到我的学校工作站。如果我运行一个程序并关闭终端,程序就会停止。我在询问 ubuntu 时读到我应该使用屏幕功能。但是,当我关闭屏幕时出现错误并且进程停止运行。我仍然可以重新连接到屏幕。
linux screen XIO: fatal IO error 11 (Resource temporarily unavailable) on X server "localhost:11.0" after 4570 requests (4570 known processed) with 192 events remaining.
我在屏幕会话上运行 GNU Parallel 命令。不幸的是,我没有在命令末尾添加“&”来将其推送到后台。因此,我无法访问我的屏幕会话中的命令行。
我想终止并行,以便它停止创建新作业但完成当前正在运行的作业。我需要在屏幕外这样做,但我认为 screen -X 不会起作用,因为屏幕的命令行不接受新命令。
谢谢!
正如标题所说,我想在我的无头盒子上设置 GNU 屏幕,这样当它启动时一些屏幕已经在运行。
我的.bashrc
文件在第一次登录时运行屏幕,screen -xRR
我希望htop
自动打开各种日志。
是否也可以同时为屏幕分配标题?
我通常将我的 GNU 屏幕分成四个区域,我真的不需要每个窗口的状态栏。
是否有禁用 GNU Screen 窗口状态栏的选项?
我只能在手册中找到始终|拆分的标题。
谢谢 :)
我已经创建了一个屏幕,但我现在可以以某种方式执行将在分离的屏幕中运行命令的命令吗?
我什至不知道这是否可能,但如果是的话,这对你来说可能是简单易行的。
感谢你的付出。
.screenrc 文件允许用户指定他们希望在第一次运行屏幕时打开多个窗口。例如。
screen -t myWindowA 0 ""
screen -t myWindowB 1 "-${SHELL}"
screen -t myWindowC 2 "-${SHELL}"
我希望每个窗口先运行一些命令,例如:
screen -t myWindowA 0 "<go to directory a, source a.sh"
screen -t myWindowB 1 "-${SHELL} <go to directory b, source b.sh>"
screen -t myWindowC 2 "-${SHELL} <go to directoy c; start a watch on `ls -l`>"
有没有办法做到这一点?
请注意,这与此 issue类似,但又有所不同。