【问题标题】:Redirect systemd script output to console将 systemd 脚本输出重定向到控制台
【发布时间】:2015-02-18 09:31:44
【问题描述】:

如何将 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

test_init_script:

#!/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)

有人知道如何将脚本输出重定向到终端吗?

【问题讨论】:

标签: linux embedded-linux systemd


【解决方案1】:

好的,所以我通过使用更改的文件构建图像来解决这个问题:

/etc/journald.conf

我将存储选项更改为易失性:

Storage=volatile

此选项意味着所有日志数据都将存储在 RAM 中,因此这是只读文件系统的一种解决方法。

请参阅期刊手册页以查看更多选项。

【讨论】:

    猜你喜欢
    • 2013-11-14
    • 2018-04-23
    • 1970-01-01
    • 2011-02-22
    • 2021-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多