redirect systemd service logs to file
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I was trying to run flume on Ubuntu 16.04 as systemd service and have following in /etc/systemd/system/flume-ng.service
[Unit]
Description=Apache Flume
[Service]
ExecStart=/usr/bin/nohup /opt/flume/current/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &
ExecStop=/opt/flume/current/bin/flume-ng agent stop
[Install]
WantedBy=multi-user.target
I tried adding following lines
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
which didn't work for me.
I did run systemctl daemon-reload
and systemctl restart flume-ng
anyone know how this works ?
linux ubuntu
add a comment |Â
up vote
2
down vote
favorite
I was trying to run flume on Ubuntu 16.04 as systemd service and have following in /etc/systemd/system/flume-ng.service
[Unit]
Description=Apache Flume
[Service]
ExecStart=/usr/bin/nohup /opt/flume/current/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &
ExecStop=/opt/flume/current/bin/flume-ng agent stop
[Install]
WantedBy=multi-user.target
I tried adding following lines
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
which didn't work for me.
I did run systemctl daemon-reload
and systemctl restart flume-ng
anyone know how this works ?
linux ubuntu
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I was trying to run flume on Ubuntu 16.04 as systemd service and have following in /etc/systemd/system/flume-ng.service
[Unit]
Description=Apache Flume
[Service]
ExecStart=/usr/bin/nohup /opt/flume/current/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &
ExecStop=/opt/flume/current/bin/flume-ng agent stop
[Install]
WantedBy=multi-user.target
I tried adding following lines
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
which didn't work for me.
I did run systemctl daemon-reload
and systemctl restart flume-ng
anyone know how this works ?
linux ubuntu
I was trying to run flume on Ubuntu 16.04 as systemd service and have following in /etc/systemd/system/flume-ng.service
[Unit]
Description=Apache Flume
[Service]
ExecStart=/usr/bin/nohup /opt/flume/current/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &
ExecStop=/opt/flume/current/bin/flume-ng agent stop
[Install]
WantedBy=multi-user.target
I tried adding following lines
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
which didn't work for me.
I did run systemctl daemon-reload
and systemctl restart flume-ng
anyone know how this works ?
linux ubuntu
linux ubuntu
asked Nov 7 '16 at 19:02
user3579198
14026
14026
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
5
down vote
ExecStart=/usr/bin/nohup â¦
This is wrong. Remove it. This service is not running in an interactive login session. There is no controlling terminal, or session leader, to send a hangup signal to it in the first place.
ExecStart=⦠&
This is wrong. Remove it. This is not shell script. &
has no special shell-like meaning, and in any case would be the wrong way to start a service.
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
These are wrong. Do not use these. systemd already sends the standard output and error of the service process(es) to its journal, without any such settings in the service unit. You can view it with
journalctl -e -u flume-ng.service
15
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
add a comment |Â
up vote
0
down vote
Use:
StandardOutput=file:/var/log/flume-ng/log1.log
StandardError=file:/var/log/flume-ng/log2.log
as documented here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
Note that this way log files contents will be overwritten each time service restarts. StandardOutput/Error
systemd directives do not support appending to files.
If you want to maintain file log between service restarts and just append new logged lines to it, use instead:
ExecStart=/usr/bin/sh -c 'exec /usr/bin/my_binary [arguments] >>/var/log/flume-ng/log1.log 2>>/var/log/flume-ng/log2.log'
exec
means that shell program will be substituted by my_binary
program after setting up redirections without forking. So there will be no difference from running my_binary
directly after ExecStart=
.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
ExecStart=/usr/bin/nohup â¦
This is wrong. Remove it. This service is not running in an interactive login session. There is no controlling terminal, or session leader, to send a hangup signal to it in the first place.
ExecStart=⦠&
This is wrong. Remove it. This is not shell script. &
has no special shell-like meaning, and in any case would be the wrong way to start a service.
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
These are wrong. Do not use these. systemd already sends the standard output and error of the service process(es) to its journal, without any such settings in the service unit. You can view it with
journalctl -e -u flume-ng.service
15
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
add a comment |Â
up vote
5
down vote
ExecStart=/usr/bin/nohup â¦
This is wrong. Remove it. This service is not running in an interactive login session. There is no controlling terminal, or session leader, to send a hangup signal to it in the first place.
ExecStart=⦠&
This is wrong. Remove it. This is not shell script. &
has no special shell-like meaning, and in any case would be the wrong way to start a service.
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
These are wrong. Do not use these. systemd already sends the standard output and error of the service process(es) to its journal, without any such settings in the service unit. You can view it with
journalctl -e -u flume-ng.service
15
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
add a comment |Â
up vote
5
down vote
up vote
5
down vote
ExecStart=/usr/bin/nohup â¦
This is wrong. Remove it. This service is not running in an interactive login session. There is no controlling terminal, or session leader, to send a hangup signal to it in the first place.
ExecStart=⦠&
This is wrong. Remove it. This is not shell script. &
has no special shell-like meaning, and in any case would be the wrong way to start a service.
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
These are wrong. Do not use these. systemd already sends the standard output and error of the service process(es) to its journal, without any such settings in the service unit. You can view it with
journalctl -e -u flume-ng.service
ExecStart=/usr/bin/nohup â¦
This is wrong. Remove it. This service is not running in an interactive login session. There is no controlling terminal, or session leader, to send a hangup signal to it in the first place.
ExecStart=⦠&
This is wrong. Remove it. This is not shell script. &
has no special shell-like meaning, and in any case would be the wrong way to start a service.
StandardOutput=/var/log/flume-ng/log1.log
StandardError=/var/log/flume-ng/log2.log
These are wrong. Do not use these. systemd already sends the standard output and error of the service process(es) to its journal, without any such settings in the service unit. You can view it with
journalctl -e -u flume-ng.service
answered Nov 7 '16 at 19:44
JdeBP
30.9k465141
30.9k465141
15
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
add a comment |Â
15
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
15
15
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
What if I wanted to send logs to a different file - is it possible or not? if possible, what is the correct way of doing this?
â AnthonyK
Mar 31 '17 at 2:13
add a comment |Â
up vote
0
down vote
Use:
StandardOutput=file:/var/log/flume-ng/log1.log
StandardError=file:/var/log/flume-ng/log2.log
as documented here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
Note that this way log files contents will be overwritten each time service restarts. StandardOutput/Error
systemd directives do not support appending to files.
If you want to maintain file log between service restarts and just append new logged lines to it, use instead:
ExecStart=/usr/bin/sh -c 'exec /usr/bin/my_binary [arguments] >>/var/log/flume-ng/log1.log 2>>/var/log/flume-ng/log2.log'
exec
means that shell program will be substituted by my_binary
program after setting up redirections without forking. So there will be no difference from running my_binary
directly after ExecStart=
.
add a comment |Â
up vote
0
down vote
Use:
StandardOutput=file:/var/log/flume-ng/log1.log
StandardError=file:/var/log/flume-ng/log2.log
as documented here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
Note that this way log files contents will be overwritten each time service restarts. StandardOutput/Error
systemd directives do not support appending to files.
If you want to maintain file log between service restarts and just append new logged lines to it, use instead:
ExecStart=/usr/bin/sh -c 'exec /usr/bin/my_binary [arguments] >>/var/log/flume-ng/log1.log 2>>/var/log/flume-ng/log2.log'
exec
means that shell program will be substituted by my_binary
program after setting up redirections without forking. So there will be no difference from running my_binary
directly after ExecStart=
.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Use:
StandardOutput=file:/var/log/flume-ng/log1.log
StandardError=file:/var/log/flume-ng/log2.log
as documented here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
Note that this way log files contents will be overwritten each time service restarts. StandardOutput/Error
systemd directives do not support appending to files.
If you want to maintain file log between service restarts and just append new logged lines to it, use instead:
ExecStart=/usr/bin/sh -c 'exec /usr/bin/my_binary [arguments] >>/var/log/flume-ng/log1.log 2>>/var/log/flume-ng/log2.log'
exec
means that shell program will be substituted by my_binary
program after setting up redirections without forking. So there will be no difference from running my_binary
directly after ExecStart=
.
Use:
StandardOutput=file:/var/log/flume-ng/log1.log
StandardError=file:/var/log/flume-ng/log2.log
as documented here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
Note that this way log files contents will be overwritten each time service restarts. StandardOutput/Error
systemd directives do not support appending to files.
If you want to maintain file log between service restarts and just append new logged lines to it, use instead:
ExecStart=/usr/bin/sh -c 'exec /usr/bin/my_binary [arguments] >>/var/log/flume-ng/log1.log 2>>/var/log/flume-ng/log2.log'
exec
means that shell program will be substituted by my_binary
program after setting up redirections without forking. So there will be no difference from running my_binary
directly after ExecStart=
.
answered 8 mins ago
Piotr Jurkiewicz
685512
685512
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f321709%2fredirect-systemd-service-logs-to-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password