Score:1

systemd service won't boot at start

mn flag

I'm running a service on a EC2 instance that should boot at start and whenever the script associated fails.

So I wrote the service like this:

[Unit]
Description=Test

[Service]
User=ubuntu
Type=simple
ExecStart=/usr/bin/ruby /home/ubuntu/main/test.rb
Restart=on-failure
RestartSec=1s

[Install]
WantedBy=multi-user.target

But when I kill the process or reboot the server, the service won't start. The service is enabled, and when I manually start it, it works as expected.

turtle avatar
sz flag
What does `journelctl --unit=Test` give you?
Voley Betz avatar
mn flag
Nothing. It runs smoothly if I start it, but it simply won't start both at boot or if i kill the process.
Voley Betz avatar
mn flag
For example now I killed it and it gives me this: ```test.service - Test Loaded: loaded (/etc/systemd/system/test.service; enabled; vendor preset: enabled) Active: inactive (dead) since Mon 2023-01-09 16:49:21 UTC; 1min 32s ago Process: 35430 ExecStart=/usr/bin/ruby /home/ubuntu/main/test.rb (code=killed, signal=TERM) Main PID: 35430 (code=killed, signal=TERM) CPU: 20.558s ```
turtle avatar
sz flag
try testing it with Restart=always, take a look at the exit status documentation here https://www.freedesktop.org/software/systemd/man/systemd.service.html
Score:0
sz flag

Restart=on-failure will not consider a 'killed process' a failure. Change Restart=on-failure to Restart=always to instruct systemd to always restart the process. See https://www.freedesktop.org/software/systemd/man/systemd.service.html

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.