Re: systemd does not generate both StandardOutput and StandardError files in /var/log/ directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Nov 5, 2021 at 2:16 PM Simon Matter <simon.matter@xxxxxxxxx> wrote:

> Hi,
>
> > Hi,
> >
> > I am running CentOS Linux release 7.9.2009 (Core). I have created a
> > systemd
> > service for a java service. I want to capture both stdout and stderr to
> > files under /var/log directory.
> > # cat /etc/redhat-release
> > CentOS Linux release 7.9.2009 (Core)
> > #
> > # rpm -qa | grep systemd
> > systemd-sysv-219-78.el7_9.3.x86_64
> > systemd-libs-219-78.el7_9.3.x86_64
> > systemd-219-78.el7_9.3.x86_64
> >
> > # cat /etc/systemd/system/smartresponse.service
> > [Unit]
> > Description=Smart Response Service
> >
> > [Service]
> > WorkingDirectory=/opt/demo
> > ExecStart=/bin/java -jar old2-wsb-smart-response-0.0.2-SNAPSHOT.jar
> > Type=simple
> > Restart=on-failure
> > RestartSec=10
> > StandardOutput=file:/var/log/smartresponseserviceoutput.log
> > StandardError=file:/var/log/smartresponseserviceerror.log
> >
> > [Install]
> > WantedBy=multi-user.target
> > #
> >
> > The files /var/log/smartresponseserviceoutput.log and
> > /var/log/smartresponseserviceoutput.log are not created. Please guide.
>
> I think the "file:" method is not supported with your version of systemd.
> See
> `man systemd.exec' for more info.
>
> You could use a shell script to work around this limitation, something like
>
> --%<---
> #!/bin/bash
>
> exec java -jar old2-wsb-smart-response-0.0.2-SNAPSHOT.jar >>
> /var/log/smartresponseserviceoutput.log 2>>
> /var/log/smartresponseserviceerror.log
> --%<---
>
> Regards,
> Simon
>
>
Thanks Simon. It worked like a charm.
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux