Systemd service, Working Directory not change the directory
The systemd WorkingDirectory=
setting defines on which directory the service will be launched, same as when you use cd
to change a directory when you're working in the shell.
That doesn't mean that all the other paths (including that from ExecStart=
) will now be relative to it, so you still need to fully specify the path to your script in that directive:
ExecStart=/home/someuser/somescript.sh
Perhaps you were thinking of the RootDirectory=
directive instead? That directory uses the chroot
command to switch the root of the filesystem seen by the process by the directory you specify, so from your use of /
for the location of the script, that looks like maybe what you wanted... However, using RootDirectory=
requires that you have a system image, with binaries and libraries under it. Like, you need to have a /bin/sh
to run your shell script, and a /lib
with a libc, etc. Typically you can't just use RootDirectory=
to just about any directory that you like...
So my advice here in order to fix the issue you're seeing is to just update the ExecStart=
to list the full path to your script.