Score:1

Enable systemd service with a parameter

jp flag

I have a systemd service with a paramter. It's working great. However, I cannot start it without a parameter.

The parameter would look like systemctl start [email protected], where the 1-0 would be parsed by a php script. The php script has a default of 1-0, but I cannot start it with systemctl start [email protected]. It tells me:

Failed to start [email protected]: Unit name [email protected] is missing the instance name.

I successfully enabled it with systemctl enable [email protected], but is it going to fail on boot? If so, how can I tell it to start with a default of 1-0 if nothing else is specified?

Score:0
jp flag

It appears that enabling a service with a default parameter is possible, per this guide. Since it needs to default to 1-0, I just did:

systemctl enable my-service\@1-0.service

It successfully created the symlink:

Created symlink /etc/systemd/system/multi-user.target.wants/[email protected] → /lib/systemd/system/[email protected]

Thanks for the downvote btw. Stay classy.

"Fine... I'll do it myself." ~ Thanos

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.