systemd: Service lacks both ExecStart= and ExecStop= setting. Refusing

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











up vote
0
down vote

favorite












I'm trying to run my app as a daemon/service on a Debian distro via systemd. Here is my service file:



[Unit]
Description=MyApp Service
After=multi-user.target

[Service]
Type=simple
Restart=always
ExecStart=sudo /usr/bin/java -jar /home/pi/myapp.jar

[Install]
WantedBy=multi-user.target


I copy that to /lib/systemd/system/myapp.service. I then run:



sudo systemctl enable myapp


I then check the status:



sudo systemctl status myapp


And I see these errors:



● myapp.service - MyApp Service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)

Sep 29 09:56:24 raspberrypi systemd[1]: [/lib/systemd/system/myapp.service:8] Executable path is not absolute, ignoring: sudo /usr/bin/java -jar /home/pi/myapp.jar
Sep 29 09:56:24 raspberrypi systemd[1]: myapp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.


When I do which java I see:



pi@raspberrypi:/lib/systemd/system $ which java
/usr/bin/java


So I'm not understanding why systemd is complaining about the executable path. Any ideas how I can troubleshoot?










share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm trying to run my app as a daemon/service on a Debian distro via systemd. Here is my service file:



    [Unit]
    Description=MyApp Service
    After=multi-user.target

    [Service]
    Type=simple
    Restart=always
    ExecStart=sudo /usr/bin/java -jar /home/pi/myapp.jar

    [Install]
    WantedBy=multi-user.target


    I copy that to /lib/systemd/system/myapp.service. I then run:



    sudo systemctl enable myapp


    I then check the status:



    sudo systemctl status myapp


    And I see these errors:



    ● myapp.service - MyApp Service
    Loaded: error (Reason: Invalid argument)
    Active: inactive (dead)

    Sep 29 09:56:24 raspberrypi systemd[1]: [/lib/systemd/system/myapp.service:8] Executable path is not absolute, ignoring: sudo /usr/bin/java -jar /home/pi/myapp.jar
    Sep 29 09:56:24 raspberrypi systemd[1]: myapp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.


    When I do which java I see:



    pi@raspberrypi:/lib/systemd/system $ which java
    /usr/bin/java


    So I'm not understanding why systemd is complaining about the executable path. Any ideas how I can troubleshoot?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to run my app as a daemon/service on a Debian distro via systemd. Here is my service file:



      [Unit]
      Description=MyApp Service
      After=multi-user.target

      [Service]
      Type=simple
      Restart=always
      ExecStart=sudo /usr/bin/java -jar /home/pi/myapp.jar

      [Install]
      WantedBy=multi-user.target


      I copy that to /lib/systemd/system/myapp.service. I then run:



      sudo systemctl enable myapp


      I then check the status:



      sudo systemctl status myapp


      And I see these errors:



      ● myapp.service - MyApp Service
      Loaded: error (Reason: Invalid argument)
      Active: inactive (dead)

      Sep 29 09:56:24 raspberrypi systemd[1]: [/lib/systemd/system/myapp.service:8] Executable path is not absolute, ignoring: sudo /usr/bin/java -jar /home/pi/myapp.jar
      Sep 29 09:56:24 raspberrypi systemd[1]: myapp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.


      When I do which java I see:



      pi@raspberrypi:/lib/systemd/system $ which java
      /usr/bin/java


      So I'm not understanding why systemd is complaining about the executable path. Any ideas how I can troubleshoot?










      share|improve this question













      I'm trying to run my app as a daemon/service on a Debian distro via systemd. Here is my service file:



      [Unit]
      Description=MyApp Service
      After=multi-user.target

      [Service]
      Type=simple
      Restart=always
      ExecStart=sudo /usr/bin/java -jar /home/pi/myapp.jar

      [Install]
      WantedBy=multi-user.target


      I copy that to /lib/systemd/system/myapp.service. I then run:



      sudo systemctl enable myapp


      I then check the status:



      sudo systemctl status myapp


      And I see these errors:



      ● myapp.service - MyApp Service
      Loaded: error (Reason: Invalid argument)
      Active: inactive (dead)

      Sep 29 09:56:24 raspberrypi systemd[1]: [/lib/systemd/system/myapp.service:8] Executable path is not absolute, ignoring: sudo /usr/bin/java -jar /home/pi/myapp.jar
      Sep 29 09:56:24 raspberrypi systemd[1]: myapp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.


      When I do which java I see:



      pi@raspberrypi:/lib/systemd/system $ which java
      /usr/bin/java


      So I'm not understanding why systemd is complaining about the executable path. Any ideas how I can troubleshoot?







      debian systemd services daemon






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 29 '17 at 10:02









      smeeb

      12516




      12516




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.



          EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:



          AmbientCapabilities=CAP_SYS_RAWIO
          User=nobody


          the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.






          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f395131%2fsystemd-service-lacks-both-execstart-and-execstop-setting-refusing%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.



            EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:



            AmbientCapabilities=CAP_SYS_RAWIO
            User=nobody


            the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.






            share|improve this answer


























              up vote
              3
              down vote



              accepted










              The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.



              EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:



              AmbientCapabilities=CAP_SYS_RAWIO
              User=nobody


              the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.






              share|improve this answer
























                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.



                EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:



                AmbientCapabilities=CAP_SYS_RAWIO
                User=nobody


                the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.






                share|improve this answer














                The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.



                EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:



                AmbientCapabilities=CAP_SYS_RAWIO
                User=nobody


                the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 30 '17 at 10:49

























                answered Sep 29 '17 at 10:15









                Johan Myréen

                6,94711423




                6,94711423



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395131%2fsystemd-service-lacks-both-execstart-and-execstop-setting-refusing%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    The Forum (Inglewood, California)

                    Palaiologos