1 Reply Latest reply on Nov 14, 2016 12:52 PM by Intel Corporation

    running code written using intel XDK on boot in loop

    ShakerBreaker

      Hi,  I've written a script using the intel XDK, I load it to the intel edison, i then run it and everything is great.  Where can I find documentation on how to make the edison run this script on boot and in a loop? Or, even better, have it run the script every hour?

       

      Thanks in advance

        • 1. Re: running code written using intel XDK on boot in loop
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello ShakerBreaker,

           

          Thanks for reaching out!

           

          In this regard, the answer will be more related to general JavaScript/Linux development than to using the XDK itself. This is due to the fact that if you'd like to set certain actions in Linux, you will have to do it through system services and shell scripts.

           

          When you have developed and tested an application, sometimes you'd like to start it automatically on boot or make it run from time to time according to a specific action (as you mentioned in your original post). In this sort of cases using the XDK will not be of much use as this directly related to how you manage your application on Linux.

           

          If you'd like to start the application from boot you'll have to create a system service. I explain how to do so in https://communities.intel.com/docs/DOC-111103. I suggest you to read that document, I believe it will be of much help for you.

           

          However, if you would like to run your script from time to time with a predetermined delay, you'll have to write a shell script and combine it with a system service. This script should not be that complex, in fact it can be very simple, for example:

           

          #!/bin/bash
          x=1
          while [ $x = 1 ]
          do
              echo "Run your script here"
              sleep 5
          done
          

           

          This would run your script every five seconds (if you replace the line ‘echo "Run your script here"’ to your script). Then you can create a system service that starts this shell script on boot. You should be able to see that your application starts on boot and runs every five seconds.

           

          Nevertheless, you must be aware that developing and working with system services sometimes can be complex and strange issues might occur. So, I suggest you to make sure that everything works perfectly before starting to develop a system service.

           

          I hope this helps.
          -Peter.