systemd not capturing echo statement from shell script

684 views Asked by At

I have a systemd service file which is directly calling a shell script. My expectation is that stdout and stderr from the file would be captured by journal+console, but it is only appearing in syslog. What should I change in my service file or the script file such that it behaves as expected?

The service file looks like:

[Unit]  
Description=Test
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
Restart=always
RestartSec=5min
TimeoutSec=5min
GuessMainPID=no
ExecStart=/tmp/script start systemd
ExecStop=/tmp/script stop systemd 
SuccessExitStatus=143
User=test
Group=test
LimitAS=infinity
LimitRSS=infinity
LimitNPROC=4096
LimitNOFILE=65536
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target graphical.target

The script actually invokes a jar but to simplify let's consider a simpler version:

#!/bin/sh
echo "ERROR:  Java not found"
exit 1

Using systemd-cat and logger I was able to direct echo statement to systlog and journald, still the log did not show up on the console.

What is the correct way to direct stdout and stderr to journal+console?

0

There are 0 answers