How to create a system service with systemd on Edison and Galileo’s eglibc image

Version 3

    Sometimes we need a script, package, program, etc. to start automatically on boot and an Arduino sketch doesn’t always fit the needs. In these kind of scenarios is where a system service is useful.

    System services on Edison are handled by systemd, this tool is an init system that some Linux distributions use to manage all processes subsequently. I will not go deeper than that in this document but if you would like to learn more about systemd I highly recommend you to read the following documents:


    systemd - Wikipedia, the free encyclopedia


    In this example I will show you how to create a system service for a simple blink example written in JavaScript. However, this also applies to any other programming language, packages, etc. (with maybe a tiny modification).

    For this example the code will be called blink.js and the service will be called blink.service. Nevertheless, these files can be called however you like as long as the service ends with the .service extension.

    The blink example will be stored in /home/root/ and it will look like the following:


    var mraa = require('mraa');
    var BLED = new mraa.Gpio(13);
    var LEDSt = true;
    function blink()
      LEDSt = !LEDSt;


    The service file has to be stored in /lib/systemd/system and it will look like this:


    Description=Edison Arduino board LED Blinker
    ExecStart=/usr/bin/node /home/root/blink.js


    Now give executable rights to blink.js with the command chmod +x blink.js.

    To enable the service type the command systemctl enable blink.service. After rebooting the board the next time, the script should start automatically.