Executing scripts at shutdown and startup

You gave me the prompt that led me to find out what was not working, for some reason I cannot yet find.

Both the two configuration was supposed to execute the same script, that simply delays the process end with “sleep”.

By inspecting the status of the second service, in my case the one supposed to be launched before login prompt, I found something like in the lines I report below.

set 15 17:44:52 rockylinux systemd[865]: wastetime2.service: Failed to execute command: Permission denied
set 15 17:44:52 rockylinux systemd[865]: wastetime2.service: Failed at step EXEC spawning /tmp/wastetime: Permission denied

The file wastetime is an executable text with the hashbang #!/bin/bash at the top.
It turned out the problem disappears if I specify the ExecStart as below.

ExecStart=/bin/sh /tmp/wastetime

It seems there’s no way to have that script executed relying just on a hashbang (I tried also with #!/bin/sh).

What I have yet to figure out is why the delay before the shutdown is noticeable and instead the delay before login prompt is not noticeable at all, though a related message appears on the screen and no errors are reported.

As for the pages I mentioned, I didn’t follow the procedure there verbatim, and I wouldn’t place a script in /tmp unless it is a dummy script, as in this case (in my previous attempts I anyway put the script elsewhere).

Thanks anyway! At least not I’m not stuck as before… :wink:

Andrea