LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-11-2020, 11:17 PM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,162

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Question Systemd custom service


Hi guys, to list all services in systemd is to just type: systemctl and press enter.

For custom services it will have an customName@service.blah.blah

Like this article below from this link: https://wiki.archlinux.org/index.php/systemd

Quote:
Note: Some unit names contain an @ sign (e.g. name@string.service): this means that they are instances of a template unit, whose actual file name does not contain the string part (e.g. name@.service). string is called the instance identifier, and is similar to an argument that is passed to the template unit when called with the systemctl command: in the unit file it will substitute the %i specifier. To be more accurate, before trying to instantiate the name@.suffix template unit, systemd will actually look for a unit with the exact name@string.suffix file name, although by convention such a "clash" happens rarely, i.e. most unit files containing an @ sign are meant to be templates. Also, if a template unit is called without an instance identifier, it will just fail, since the %i specifier cannot be substituted
My question is, how to stop or restart the custom service by calling the service name.

Example if the name is like this: javaservice@name.service

The command to restart would be like this:

systemctl restart javaservice

It will be like that? Or how do we find the exact name to call the custom service?

Thank you.
 
Old 04-12-2020, 03:21 AM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,838

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Quote:
For custom services it will have an customName@service.blah.blah
That's not necessarily true as such. This is only the case when defining a template unit file (to support multiple instances of a given unit).

Quote:
Example if the name is like this: javaservice@name.service
If you just want to restart that particular instance
Code:
sudo systemctl restart javaservice@name.service
To restart all instances you could use a wild card like this
Code:
sudo systemctl restart 'javaservice@*'
This may be of interest...
https://fedoramagazine.org/systemd-template-unit-files/
 
1 members found this post helpful.
Old 04-14-2020, 02:58 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,162

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Thanks Ferrari, Cheers!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Systemd service: AUTOSSH.service does not start at boot, how can I fix this? The_Linux_Machine Linux - Newbie 1 07-06-2016 12:00 PM
Can't access full journalctl from script via systemd service even though user is in systemd-journal group iwtbf Linux - Newbie 0 02-19-2016 02:44 PM
custom systemd httpd service fails to start on centos 7 mariogarcia CentOS 3 02-13-2016 02:51 AM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration