Fix systemd status=2/INVALIDARGUMENT
Trace systemd status=2/INVALIDARGUMENT to the command that exited, read its journal error, and verify the corrected ExecStart arguments.
gb-list.service: Main process exited, code=exited, status=2/INVALIDARGUMENTIn status=2/INVALIDARGUMENT, 2 is the exit code. systemd v255 labels that value INVALIDARGUMENT. Read the program's journal entries just before the exit to identify the rejected option or value. GNU ls also exits with 2 when it fails to inspect a file named on the command line. systemd.exec(5) exit codes · GNU ls source
[1] Find the command that exited. Substitute your unit name for the example gb-list.service.
$ systemctl status gb-list.service --no-pager --lines=0 Process: 124 ExecStart=/usr/bin/ls --not-an-option (code=exited, status=2) Main PID: 124 (code=exited, status=2)In this test, systemctl status displayed status=2. Read the Process: line for the ExecStart= command and arguments. If the line names ExecStartPre=, check that pre-start command.
Read the unit's journal for the exit code's label and the application's error. Omit -o cat to see timestamps.
$ journalctl -u gb-list.service -b --no-pager -o catStarting gb-list.service.../usr/bin/ls: unrecognized option '--not-an-option'Try '/usr/bin/ls --help' for more information.gb-list.service: Main process exited, code=exited, status=2/INVALIDARGUMENTgb-list.service: Failed with result 'exit-code'.Failed to start gb-list.service.[2] Compare the command systemd loaded with the configuration on disk.
$ systemctl show gb-list.service -p ExecStart -p ExecStartPre -p Result -p ExecMainStatus$ systemctl cat gb-list.service --no-pagershow displays the service manager's current command. cat displays the unit file and its drop-ins. If a recent edit is missing from the loaded command, check whether the manager has reloaded the files. If the command is a wrapper script, check what it calls and which arguments it passes. If the journal is empty, check StandardError= and the location of the program's own logs. Use the same sequence when a program returns 1. systemctl(1) · Diagnose systemd status=1/FAILURE
[3] Check the arguments against the installed program's help. In the example, ls rejected --not-an-option. With -d /usr/bin, it lists the directory itself. For a program that changes data, check for a validation mode before rerunning it manually.
[4] Correct the failing line and check the service again. This example replaces ExecStart= in a dedicated drop-in. Choose an unused filename and check systemctl cat for any later drop-in that changes the command again. The empty assignment clears the previous command list. For a Type=oneshot service with multiple start commands, include all commands you want to keep in their original order. systemd.service(5) ExecStart=
[Service]ExecStart=ExecStart=/usr/bin/ls -d /usr/binFor a unit that stopped on failure, reload the unit files and start it. Applying the change to a running service requires a restart, so schedule it when an interruption is acceptable. To roll back, remove the drop-in created in this step and reload the unit files. Schedule a restart to restore the earlier command if the service is running with the change.
$ sudo systemctl daemon-reload$ sudo systemctl start gb-list.serviceAfter the arguments were corrected, these lines appeared at the end of the unit journal.
$ journalctl -u gb-list.service -b --no-pager -o catStarting gb-list.service.../usr/binFinished gb-list.service.$ systemctl show gb-list.service -p Result -p ExecMainCode -p ExecMainStatusResult=successExecMainCode=1ExecMainStatus=0If the start limit was reached, fix the cause, clear the counter with sudo systemctl reset-failed gb-list.service, and start it. Check the status and journal for the latest attempt. For a short-lived command, check the exit code and expected output. For a long-running service, check its running state and program logs. systemctl(1)
Analyze your syslog · journal log in the browser ↗ — nothing is uploaded.