Systemctl restart service triggering another command












0















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










share|improve this question

























  • 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











  • 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
















0















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










share|improve this question

























  • 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











  • 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














0












0








0








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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











  • 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 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











  • 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 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










1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    1














    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.






    share|improve this answer




























      1














      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.






      share|improve this answer


























        1












        1








        1







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 22 at 14:28









        Jeff SchallerJeff Schaller

        43.3k1160140




        43.3k1160140






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀