Systemctl restart service triggering another command
I created systemd service, which runs a script that auto-generates some configuration files if these don't exist, and loads the services depending on them, or loads the services with the existing ones.
I would like to provide some extra functionality, allowing the user to clean previous configurations using the same systemctl service.
I thought in ExecReload
, thinking that it would be called when the user types systemctl restart service_name
, but then I discovered that it is not doing what I thought.
Is there a way to do i?
I was checking here and in Freedesktop Systemd doc, but I could not find the way
systemd systemctl
add a comment |
I created systemd service, which runs a script that auto-generates some configuration files if these don't exist, and loads the services depending on them, or loads the services with the existing ones.
I would like to provide some extra functionality, allowing the user to clean previous configurations using the same systemctl service.
I thought in ExecReload
, thinking that it would be called when the user types systemctl restart service_name
, but then I discovered that it is not doing what I thought.
Is there a way to do i?
I was checking here and in Freedesktop Systemd doc, but I could not find the way
systemd systemctl
The trouble is that you're limited tosystemctl
's interface, which means verbs likestart
,stop
, orreload
, which you probably don't want to overload. Are you open to using something besidessystemctl
as the interface to this?
– Jeff Schaller
Feb 22 at 12:57
yes, thank you: finally I created a script in /sbin to clean, re-build the configuration and reload the service
– xCovelus
Feb 22 at 13:14
The command inExecReload=
is executed when you runsystemctl reload
, notrestart
(which doessrop
followed bystart
.) I guess it's not completely clear to me what you're trying to accomplish, would you care to give more details, like a more detailed description of what config files you want to generate and which services you want to start/restart/reload from your custom service? That would help us give you a better suggestion on how to accomplish what you're trying to do... Thanks!
– filbranden
Feb 23 at 7:23
add a comment |
I created systemd service, which runs a script that auto-generates some configuration files if these don't exist, and loads the services depending on them, or loads the services with the existing ones.
I would like to provide some extra functionality, allowing the user to clean previous configurations using the same systemctl service.
I thought in ExecReload
, thinking that it would be called when the user types systemctl restart service_name
, but then I discovered that it is not doing what I thought.
Is there a way to do i?
I was checking here and in Freedesktop Systemd doc, but I could not find the way
systemd systemctl
I created systemd service, which runs a script that auto-generates some configuration files if these don't exist, and loads the services depending on them, or loads the services with the existing ones.
I would like to provide some extra functionality, allowing the user to clean previous configurations using the same systemctl service.
I thought in ExecReload
, thinking that it would be called when the user types systemctl restart service_name
, but then I discovered that it is not doing what I thought.
Is there a way to do i?
I was checking here and in Freedesktop Systemd doc, but I could not find the way
systemd systemctl
systemd systemctl
edited Feb 22 at 13:06
Rui F Ribeiro
41.5k1481140
41.5k1481140
asked Feb 22 at 12:17
xCovelusxCovelus
436
436
The trouble is that you're limited tosystemctl
's interface, which means verbs likestart
,stop
, orreload
, which you probably don't want to overload. Are you open to using something besidessystemctl
as the interface to this?
– Jeff Schaller
Feb 22 at 12:57
yes, thank you: finally I created a script in /sbin to clean, re-build the configuration and reload the service
– xCovelus
Feb 22 at 13:14
The command inExecReload=
is executed when you runsystemctl reload
, notrestart
(which doessrop
followed bystart
.) I guess it's not completely clear to me what you're trying to accomplish, would you care to give more details, like a more detailed description of what config files you want to generate and which services you want to start/restart/reload from your custom service? That would help us give you a better suggestion on how to accomplish what you're trying to do... Thanks!
– filbranden
Feb 23 at 7:23
add a comment |
The trouble is that you're limited tosystemctl
's interface, which means verbs likestart
,stop
, orreload
, which you probably don't want to overload. Are you open to using something besidessystemctl
as the interface to this?
– Jeff Schaller
Feb 22 at 12:57
yes, thank you: finally I created a script in /sbin to clean, re-build the configuration and reload the service
– xCovelus
Feb 22 at 13:14
The command inExecReload=
is executed when you runsystemctl reload
, notrestart
(which doessrop
followed bystart
.) I guess it's not completely clear to me what you're trying to accomplish, would you care to give more details, like a more detailed description of what config files you want to generate and which services you want to start/restart/reload from your custom service? That would help us give you a better suggestion on how to accomplish what you're trying to do... Thanks!
– filbranden
Feb 23 at 7:23
The trouble is that you're limited to
systemctl
's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. Are you open to using something besides systemctl
as the interface to this?– Jeff Schaller
Feb 22 at 12:57
The trouble is that you're limited to
systemctl
's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. Are you open to using something besides systemctl
as the interface to this?– Jeff Schaller
Feb 22 at 12:57
yes, thank you: finally I created a script in /sbin to clean, re-build the configuration and reload the service
– xCovelus
Feb 22 at 13:14
yes, thank you: finally I created a script in /sbin to clean, re-build the configuration and reload the service
– xCovelus
Feb 22 at 13:14
The command in
ExecReload=
is executed when you run systemctl reload
, not restart
(which does srop
followed by start
.) I guess it's not completely clear to me what you're trying to accomplish, would you care to give more details, like a more detailed description of what config files you want to generate and which services you want to start/restart/reload from your custom service? That would help us give you a better suggestion on how to accomplish what you're trying to do... Thanks!– filbranden
Feb 23 at 7:23
The command in
ExecReload=
is executed when you run systemctl reload
, not restart
(which does srop
followed by start
.) I guess it's not completely clear to me what you're trying to accomplish, would you care to give more details, like a more detailed description of what config files you want to generate and which services you want to start/restart/reload from your custom service? That would help us give you a better suggestion on how to accomplish what you're trying to do... Thanks!– filbranden
Feb 23 at 7:23
add a comment |
1 Answer
1
active
oldest
votes
The trouble is that you're limited to systemctl's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. My suggestion would be to use a separate interface altogether, such as a kill -USR1
signal handler or a separate script that you can invoke.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502281%2fsystemctl-restart-service-triggering-another-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The trouble is that you're limited to systemctl's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. My suggestion would be to use a separate interface altogether, such as a kill -USR1
signal handler or a separate script that you can invoke.
add a comment |
The trouble is that you're limited to systemctl's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. My suggestion would be to use a separate interface altogether, such as a kill -USR1
signal handler or a separate script that you can invoke.
add a comment |
The trouble is that you're limited to systemctl's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. My suggestion would be to use a separate interface altogether, such as a kill -USR1
signal handler or a separate script that you can invoke.
The trouble is that you're limited to systemctl's interface, which means verbs like start
, stop
, or reload
, which you probably don't want to overload. My suggestion would be to use a separate interface altogether, such as a kill -USR1
signal handler or a separate script that you can invoke.
answered Feb 22 at 14:28
Jeff SchallerJeff Schaller
43.3k1160140
43.3k1160140
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502281%2fsystemctl-restart-service-triggering-another-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The trouble is that you're limited to
systemctl
's interface, which means verbs likestart
,stop
, orreload
, which you probably don't want to overload. Are you open to using something besidessystemctl
as the interface to this?– Jeff Schaller
Feb 22 at 12:57
yes, thank you: finally I created a script in /sbin to clean, re-build the configuration and reload the service
– xCovelus
Feb 22 at 13:14
The command in
ExecReload=
is executed when you runsystemctl reload
, notrestart
(which doessrop
followed bystart
.) I guess it's not completely clear to me what you're trying to accomplish, would you care to give more details, like a more detailed description of what config files you want to generate and which services you want to start/restart/reload from your custom service? That would help us give you a better suggestion on how to accomplish what you're trying to do... Thanks!– filbranden
Feb 23 at 7:23