242

サービスの出力をファイルにリダイレクトしようとしsystemdていますが、うまくいかないようです:

[Unit]
Description=customprocess
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/binary1 agent -config-dir /etc/sample.d/server
StandardOutput=/var/log1.log
StandardError=/var/log2.log
Restart=always

[Install]
WantedBy=multi-user.target

私のアプローチを修正してください。

4

8 に答える 8

56

次のエラーが発生する可能性があります。

Failed to parse output specifier, ignoring: /var/log1.log

systemd.exec(5)マニュアルページから:

StandardOutput=

実行されたプロセスのファイル記述子 1 (STDOUT) が接続される場所を制御します。、、、、、、、、、またはのいずれかinheritを取ります。_ _nullttyjournalsyslogkmsgjournal+consolesyslog+consolekmsg+consolesocket

systemd.exec(5)man ページでは、ロギングに関連するその他のオプションについて説明しています。systemd.service(5)およびsystemd.unit(5)man ページも参照してください。

または、次のようなことを試すこともできます (すべて 1 行で):

ExecStart=/bin/sh -c '/usr/local/bin/binary1 agent -config-dir /etc/sample.d/server 2>&1 > /var/log.log' 
于 2016-06-02T15:11:20.650 に答える