Trying to put my script/binary into a service does not work properly.
systemd.user.services.datensicherung = {
enable = true;
after = [ "network.target" ];
wantedBy = [ "default.target" ];
description = "Datensicherung";
serviceConfig = {
Type = "simple";
ExecStart = ''/home/xxx/datensicherung'';
};
};
Starting the script/binary (/home/xxx/datensicherung) manually works fine.
Starting the script/binary via service does not write to the external disk (/run/media/datensicherung/), but writing the logs to the local disk (/home/xxx/) works.
so how do you mount the external disk? after logging in?
may you include some kind of logging into your script and then check what’s exactly wrong
systemctl --user start datensicherung.service
systemctl --user status datensicherung.service
journalctl --user -xeu datensicherung.service
When the script is started by systemd it runs in a completely different (empty) environment compared to your login shell.
You need to add the packages you need to systemd.user.services.<name>.path, define environment variables with systemd.user.services.<name>.environment, etc.
Also, note that network.target does not exist for user services.
3 Likes