Contents
How to add stdout to systemd service file?
The file:path option is documented in the most recent systemd.exec man page. This new feature is relatively new and so is not available for older distros like centos-7 (or any centos before that). I would suggest adding stdout and stderr file in systemd service file itself.
How to redirect output of systemd service to a file?
StandardOutput= Controls where file descriptor 1 (STDOUT) of the executed processes is connected to. Takes one of inherit, null, tty, journal, syslog, kmsg, journal+console, syslog+console, kmsg+console or socket. The systemd.exec (5) man page explains other options related to logging.
How to set standardoutput in systemd.exec?
In newer versions of systemd there is a relatively new option ( the github request is from 2016 ish and the enhancement is merged/closed 2017 ish) where you can set the values of StandardOutput or StandardError to file:YOUR_ABSPATH_FILENAME. The file:path option is documented in the most recent systemd.exec man page.
Where can I find stdout and stderr files?
Your program stdout/stderr will still be available through journalctl ( sudo journalctl -u ) but they will also be available in your file of choice. If you have a newer distro with a newer systemd ( systemd version 236 or newer ), you can set the values of StandardOutput or StandardError to file:YOUR_ABSPATH_FILENAME.
How does BusyBox init work in syslog?
These will be held in a circular buffer in the kernel until userspace (of pretty much all distros) dump it into syslog after the filesystem is made writable and disk checks have run. This will work as long as your kernel buffer is larger than the size of the messages that happen before the logger is started.
Which is run before RC or after syslog?
The rc script is run before syslog, which means that all usefull information from rc is lost. (I’m not sure, what the touch command is for btw.) I could start syslog before rc (null::sysinit:/sbin/syslogd…), but that would remove the very important ‘respawn’.