-1

I have this very simple systemd.

[Unit]
Description="Something"

[Service]
Type=simple
ExecStart=/bin/systemctl restart nginx

When I try to run it, using systemctl start my-script.service, and I query it using systemctl status my-script.service, it shows status Loaded, and will do so for all eternity.

I have the feeling, the issue is that I want to use systemctl from within systemd.

1

systemctl status will reported "Loaded" for your service because it is indeed loaded into systemd at that point. I'm not sure what else you were expecting. I tried starting your service myself and it worked as expected, issuing a restart to the Nginx service:

$ journalctl | tail -10
Apr 27 12:39:28 myhost.com systemd[1]: Started "Something".
Apr 27 12:39:28 myhost.com systemd[1]: Stopping A high performance web server and a reverse proxy server...
Apr 27 12:39:28 myhost.com systemd[1]: Stopped A high performance web server and a reverse proxy server.
Apr 27 12:39:28 myhost.com systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 27 12:39:28 myhost.com systemd[1]: Started A high performance web server and a reverse proxy server. 

If your systemd service file is not working as expected, please be more specific in your question.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.