Fix systemd status=209/STDOUT
Fix systemd status=209/STDOUT by checking where StandardOutput= points. Use the journal error to find a missing parent directory or a bad output path.
When you see status=209/STDOUT, check the unit’s output destination. With StandardOutput=file:/run/gb-missing/out.txt, a missing /run/gb-missing directory prevents systemd from opening the file. In v255, systemd sets up standard output before running the ExecStart= program.
[1] The test unit failed to start with StandardOutput=file:/run/gb-missing/out.txt. Check the process lines in its status and read the journal.
# systemctl status gb-stdout.service --no-pager --lines=0 Process: 106 ExecStart=/usr/bin/echo gb-stdout-ok (code=exited, status=209/STDOUT) Main PID: 106 (code=exited, status=209/STDOUT)# journalctl -u gb-stdout.service -b --no-pager -o catgb-stdout.service: Failed to set up standard output: No such file or directoryStarting gb-stdout.service - /usr/bin/echo gb-stdout-ok...gb-stdout.service: Main process exited, code=exited, status=209/STDOUTgb-stdout.service: Failed with result 'exit-code'.Failed to start gb-stdout.service - /usr/bin/echo gb-stdout-ok.On your system, replace myapp.service with the failed unit’s name. Read the error after Failed to set up standard output: in the journal.
$ sudo journalctl -b -u myapp.service --no-pager -n 40$ systemctl cat myapp.servicesystemctl cat shows the main unit file and its drop-ins. Find where [Service] sets StandardOutput=. After a file edit, what you see on disk can differ from the manager’s loaded configuration until you run daemon-reload. If the status reads status=1/FAILURE, look for messages from the program itself. Find the cause of systemd status=1/FAILURE
[2] Follow each component of the path after file:. Substitute the path from your unit.
$ namei -l /run/gb-missing/out.txtFor No such file or directory, look for a missing parent directory or a broken symlink. file: can create the final regular file, and its parent directory must already exist. If the entire path exists, follow the journal error. For Is a directory, check whether the destination itself is a directory. For Read-only file system, check whether the destination mount allows writes.
[3] If the service needs file output, prepare the parent directory before starting the unit. /run is cleared on reboot, so arrange to create the directory during deployment or boot. The v255 source sets up standard output before preparing the same unit’s RuntimeDirectory=. Relying on that setting alone can leave the output file’s parent missing on the first start.
If the journal is an acceptable destination, check that the following drop-in name is unused before adding it. If you edit an existing file, record the previous value.
[Service]StandardOutput=journal[4] Start the failed unit again and verify that output reaches its destination. Run sudo systemctl daemon-reload first if you changed a unit file or drop-in.
$ sudo systemctl start myapp.service$ systemctl status myapp.service --no-pager$ sudo journalctl -b -u myapp.service --no-pager -n 20If you kept file output, check the destination for fresh output. If the unit hit its start-rate limit, run reset-failed for that unit first. Find why a systemd service failed
In the test, creating the parent directory and starting the same unit again gave ExecMainStatus=0 and wrote gb-stdout-ok to the file.
# mkdir /run/gb-missing# systemctl start gb-stdout.service# systemctl show gb-stdout.service -p Result -p ExecMainStatus# cat /run/gb-missing/out.txtResult=successExecMainStatus=0gb-stdout-okAnalyze your syslog · journal log in the browser ↗ — nothing is uploaded.