How to run a command in power up or shutdown (NOT reboot)?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have some EC2 instances and I wanted to run a command whenever an instance is created or terminated. Some of the solutions that AWS offers are not very simple (like using SNS topics and using lifecycle hooks), so they are not an option for me.



One my options was running a script in init.d. However, I wanted to find some option where the command runs only at power up or shutdown, not on reboot.



Is there any kind of linux service that can reliably determine if the system is powering up or shutting down and run a command?










share|improve this question







New contributor




Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    1
    down vote

    favorite












    I have some EC2 instances and I wanted to run a command whenever an instance is created or terminated. Some of the solutions that AWS offers are not very simple (like using SNS topics and using lifecycle hooks), so they are not an option for me.



    One my options was running a script in init.d. However, I wanted to find some option where the command runs only at power up or shutdown, not on reboot.



    Is there any kind of linux service that can reliably determine if the system is powering up or shutting down and run a command?










    share|improve this question







    New contributor




    Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have some EC2 instances and I wanted to run a command whenever an instance is created or terminated. Some of the solutions that AWS offers are not very simple (like using SNS topics and using lifecycle hooks), so they are not an option for me.



      One my options was running a script in init.d. However, I wanted to find some option where the command runs only at power up or shutdown, not on reboot.



      Is there any kind of linux service that can reliably determine if the system is powering up or shutting down and run a command?










      share|improve this question







      New contributor




      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have some EC2 instances and I wanted to run a command whenever an instance is created or terminated. Some of the solutions that AWS offers are not very simple (like using SNS topics and using lifecycle hooks), so they are not an option for me.



      One my options was running a script in init.d. However, I wanted to find some option where the command runs only at power up or shutdown, not on reboot.



      Is there any kind of linux service that can reliably determine if the system is powering up or shutting down and run a command?







      init-script amazon-ec2






      share|improve this question







      New contributor




      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Oct 4 at 5:07









      Filipe Rodrigues

      62




      62




      New contributor




      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Filipe Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          active

          oldest

          votes











          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Filipe Rodrigues is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473140%2fhow-to-run-a-command-in-power-up-or-shutdown-not-reboot%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Filipe Rodrigues is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          Filipe Rodrigues is a new contributor. Be nice, and check out our Code of Conduct.












          Filipe Rodrigues is a new contributor. Be nice, and check out our Code of Conduct.











          Filipe Rodrigues is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473140%2fhow-to-run-a-command-in-power-up-or-shutdown-not-reboot%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay