TLDR: Created service does not execute a .sh script as intended.
Hi all,
I am fairly new to this forum so please excuse me if this posted in the wrong section of the forum.
I want to create a service for my Ubuntu Server 19.04, I want to run a bash script when the service starts. Simple script pure for testing. The document and .sh file are in the same directory and the script works as intended.
The service can run and will show as active with systemctl status. However the script will not be executed. Hello will not be appended to the file nor will it be created. Does anyone know where I go wrong, As far as I know the service file itself does not need to be executable.
Have you tried running the script outside of Systemd?
I am pretty sure that systemd runs services as root unless specified otherwise in the service file. So either manually specify your user as the user to run the service under, or make sure root has permissions to run the script correctly.
so for clarification:
the script works fine when run manually eg ./test
the script does not work properly when run via systemd (and no systemd errors in journalctl) .
systemd says the script is running fine
note: i believe that systemd has no $PATH variable; i believe it runs as root (similar to cron, which also has no $PATH) . thats why i said you need to specify full paths.
it will eliminate that possibility.