5 Replies Latest reply on Jun 15, 2015 5:43 AM by Ashish9433

    Startup Scripts?


      What's the formal out-of-the-box method to run startup scripts on edison?

        • 1. Re: Startup Scripts?

          I am not sure exactly what you want to do, but I suspect systemd is what you want


          Helpful links:



          SysVinit to Systemd Cheatsheet - FedoraProject



          basically you make 'services' (text files that specify the program(s) you want to run) and put them in the '/lib/systemd/system/' folder


          then you run 'systemctl enable myservice' to enable the service at bootime, there are all sorts of parameters to restart the service if the process dies, or start the service before or after network interfaces are brought up.



          Edit: I am not sure why my service file was auto renamed to .zip (either the forum auto zips files, or you will have to rename the file to my-service.service)

          1 of 1 people found this helpful
          • 2. Re: Startup Scripts?

            Just to add to Dan's response above...


            Add a new service script to /lib/systemd/system - have a look at the scripts there alread, a good example is the iotkit-agent.service script.

            So you then have yourscript.service file.

            To start, first refresh systemd, then try to start your new service

               systemctl daemon-reload

               systemcrl start yourscript.service


            You can then use 'systemctl status yourscript.service' to see if it's started and alive.


            If you want it to start at boot, you have to 'enable' it

               systemcrl enable yourscript.service  

            which creates a softlink to your script from the relevant directory in /etc/systemd/system/...

            Now reboot and see if it comes up ok.


            If your script calls a binary that needs environment vars set up, be sure to include them in the script, LD_LIBRARY_PATH is a common var needed:


            export LD_LIBRARY_PATH




            1 of 1 people found this helpful
            • 3. Re: Startup Scripts?

              Hi David_J_Hunt,


              I tried  the steps in the mentioned link but i am getting the following error


              Active: activating (auto-restart) (Result: exit-code) since Fri 2015-02-27 21:18:35 PKT; 2s ago

              Process: 1153 ExecStart=/home/wakaama-client/bash myscript.sh (code=exited, status=203/EXEC)

              Main PID: 1153 (code=exited, status=203/EXEC)

              Feb 27 21:18:35 galileo systemd[1]: lwm2m.service: main process exited, code=exited, status=203/EXEC

              Feb 27 21:18:35 galileo systemd[1]: Unit lwm2m.service entered failed state.

              When i manually run the myscript.sh from terminal it works perfectly fine, but when i followed the mentioned steps and checked the status, i get above error.


              myscript.sh file content




              lwm2mclient is the binary which i want to get executed on every startup.


              can you please help me to resolve this error?

              • 4. Re: Startup Scripts?

                Hi David_J_Hunt


                I just changed my script file to below and it worked!


                myscript.sh file content




                Inshort i gave the full path of the executable and it started working.


                But i have another issue is on reboot when i check the status of my service i get following result


                  lwm2m.service - LWM2M Startup Agent

                  Loaded: loaded (/lib/systemd/system/lwm2m.service; disabled)

                  Active: inactive (dead)

                I tried changing type = fork as mentioned in some of the forums (Man page systemd.service) but it didn't work. In terminal when i run this command "systemctl start lwm2m.service" but on restart it doesn't, can you please guide me how to fix this?

                • 5. Re: Startup Scripts?

                  I some how missed doing "systemcrl enable yourscript.service" and hence i was getting the above error. Its fixed and working now!


                  Thanks everyone for your help and support!