I’ve created the following systemd service:
[Unit] Description=ISPConfig DC Sync After=network.target After=mysql.service After=nginx.service [Service] User=root Group=root Type=simple ExecStart=/usr/local/ispconfig/server/server.sh [Install] WantedBy=multi-user.target
The (.sh) command has a loop that returns a message stating whether it had an error or was successful. The problem is that this result is printed in the messages (/var/log/messages) log. There’s a way to prevent this? (Preferably in the specifications of the own service)
The documentation states that you can set
StandardError= to whatever you want. They default to the journal, but you can redirect them to any of several places.
Controls where file descriptor 1 (STDOUT) of the executed processes is connected to. Takes one of
nullconnects standard output to
/dev/null, i.e. everything written to it will be lost.
StandardError= is similar, with an important exception to how it
inherits (which is also the default):
Controls where file descriptor 2 (STDERR) of the executed processes is connected to. The available options are identical to those of
StandardOutput=, with some exceptions: if set to
inheritthe file descriptor used for standard output is duplicated for standard error, while
fdoperates on the error stream and will look by default for a descriptor named
So, you can do this:
[Service] StandardOutput=null StandardError=journal
But keep in mind that you will lose the output from the script; more importantly, if there is a problem and the script outputs an error on standard output instead of standard error (as many shell scripts do), you will lose that as well. When something goes wrong, this will cause you a whole lot of unnecessary frustration.
So, you really should do nothing to the systemd unit. Rather, if you don’t want the script to output anything on success, fix the script.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.