如何将由 systemd ExecStart 脚本运行的脚本输出重定向到引导控制台?
我需要在启动前调试脚本的问题,但我不能使用 journalctl,因为它是带有 ROM rootfs 的嵌入式 linux。
现在我的 .service 文件如下所示:
[Unit]
Description=Init script
After=network.target
Before=getty@tty1.service
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/test_init_script
ExecStartPre=/usr/bin/echo -e \033%G
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory=/
Enviroment=TERM=xterm
[Install]
WantedBy=multi-user.target
测试初始化脚本:
#!/bin/sh -
echo "Test!"
它没有用,启动后我收到消息:
#systemctl status test_init_script.service
test_init_script.service - Init script
Loaded: loaded (/usr/lib/systemd/test_init_script.service)
Active: failed (Result: exit-code) Since Thu 1970-01-01 08:26:03 CST; 19s ago
Process: 170 ExecStartOre=/usr/bin/echo -e -G (code=exited, status=203/EXEC)
有人知道如何将脚本输出重定向到终端吗?
最佳答案
好的,所以我通过使用更改的文件构建图像来解决这个问题:
/etc/journald.conf
我将存储选项更改为 volatile 的地方:
Storage=volatile
此选项意味着所有日志数据都将存储在 RAM 中,因此这是只读文件系统的解决方法。
请参阅journald 手册页以查看更多选项。
关于linux - 将 systemd 脚本输出重定向到控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28580081/