dtach 在 systemd 服务文件中
dtach in systemd service file
as screen 与 python-newt 库结合使用会在我们当前的设置中导致段错误 我正在寻找一个程序来替代 screen。
该系统绝对是最小的,只需要执行一个 python-脚本来安装未来的 OS.
我找到了 dtach (http://linux.die.net/man/1/dtach)。
我可以 运行 我想要的脚本,在 运行ning tty 会话中使用命令。
dtach -c /tmp/test /usr/local/bin/master.py
我还可以附加到 运行ning 会话等。
此外,我需要在启动时设置 ut 运行,因为屏幕前的用户必须能够输入不存在的值。
我制作了以下位于 /etc/systemd/system/master.service
的 systemd 服务文件
[Unit]
Description=Job that starts the master.py
Requires=premaster.service
After=premaster.service
[Service]
Type=simple
ExecStart=/usr/bin/dtach -c /tmp/master /usr/local/bin/master.py
[Install]
WantedBy=multi-user.target
并在启动时使用
启用它
systemctl enable /etc/systemd/system/master.service
premaster 位于 /etc/init.d/premaster 并按预期执行
当我 运行 master.service 我得到以下错误
/usr/bin/dtach: Attaching to a session requires a terminal
修复了以下文件:
master.service
[Unit]
Description=Job that starts the master.py
Requires=opsi.service
After=opsi.service
After=getty@tty6.service
[Service]
Environment=TERM=linux
Type=simple
ExecStart=/usr/local/bin/master.sh
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty6
[Install]
WantedBy=multi-user.target
master.sh
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
vt=6
sleep 1
chvt $vt
sleep 1
chvt $vt
. /etc/environment
export LANGUAGE
export LANG
export LC_ALL
dtach -A /tmp/bootimage master.py
使用此配置,它可以正常工作并在启动时直接引导至 TTY6。此外,它是交互式的,以防用户必须输入配置中缺少的内容。
也许有人需要它。
as screen 与 python-newt 库结合使用会在我们当前的设置中导致段错误 我正在寻找一个程序来替代 screen。 该系统绝对是最小的,只需要执行一个 python-脚本来安装未来的 OS.
我找到了 dtach (http://linux.die.net/man/1/dtach)。 我可以 运行 我想要的脚本,在 运行ning tty 会话中使用命令。
dtach -c /tmp/test /usr/local/bin/master.py
我还可以附加到 运行ning 会话等。 此外,我需要在启动时设置 ut 运行,因为屏幕前的用户必须能够输入不存在的值。
我制作了以下位于 /etc/systemd/system/master.service
的 systemd 服务文件[Unit]
Description=Job that starts the master.py
Requires=premaster.service
After=premaster.service
[Service]
Type=simple
ExecStart=/usr/bin/dtach -c /tmp/master /usr/local/bin/master.py
[Install]
WantedBy=multi-user.target
并在启动时使用
启用它systemctl enable /etc/systemd/system/master.service
premaster 位于 /etc/init.d/premaster 并按预期执行
当我 运行 master.service 我得到以下错误
/usr/bin/dtach: Attaching to a session requires a terminal
修复了以下文件:
master.service
[Unit]
Description=Job that starts the master.py
Requires=opsi.service
After=opsi.service
After=getty@tty6.service
[Service]
Environment=TERM=linux
Type=simple
ExecStart=/usr/local/bin/master.sh
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty6
[Install]
WantedBy=multi-user.target
master.sh
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
vt=6
sleep 1
chvt $vt
sleep 1
chvt $vt
. /etc/environment
export LANGUAGE
export LANG
export LC_ALL
dtach -A /tmp/bootimage master.py
使用此配置,它可以正常工作并在启动时直接引导至 TTY6。此外,它是交互式的,以防用户必须输入配置中缺少的内容。
也许有人需要它。