gpt4 book ai didi

logging - Upstart 控制台输出不起作用

转载 作者:行者123 更新时间:2023-12-04 15:31:54 32 4
gpt4 key购买 nike

我使用了 Upstart 为 console output 提供的示例.

/etc/init/test.conf

console output

pre-start script

# Perform whatever checks you like here (maybe checking
# '/etc/default/foo' to see if the service is enabled # or not).
#
# if there are no problems detected, simply "exit 0", else do
# something like this...

# display an error message to stderr *on the console* and also write
# the same message to the system log.
logger -is -t "$UPSTART_JOB" "ERROR: foo!"

# tell Upstart not to start the main process for the job.
exit 1
end script

# this service doesn't do much :-)
exec sleep 999

然后作为根
$ initctl start test
initctl: Job failed to start

该消息存在于 /var/log/syslog ,但该消息未出现在控制台中。
Jul 23 07:42:19 paul test[26595]: ERROR: foo!

如何将错误记录到控制台?

这是 Ubuntu 14.04,
$ initctl version
init (upstart 1.12.1)

最佳答案

console output写信给 /dev/console ,默认情况下,它是系统虚拟日志记录设备:它不会写入您的个人控制台(例如 /dev/tty0 )。

如果您尝试直接写入这些虚拟设备,您实际上可以测试行为的差异:

sudo echo test >> /dev/console     # Won't work
sudo su; echo test >> /dev/console # Works but nothing prints
sudo echo test >> /dev/tty0 # Works and prints

有关不同虚拟控制台设备之间差异的更多信息,请参阅 this Unix StackExchange question .

如果你真的想要,你可以改变什么 /dev/console通过修改引导配置指向:
# /etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"

...但如果我是你,我只会使用 console log节而不是 console output然后拖尾生成的文件。

关于logging - Upstart 控制台输出不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38542470/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com