New Guide: Running Programs Automatically on Your Tiny Computer

checklist

Just posted, a new guide in our introductory Linux series, this one on using the init system to automatically start stuff at boot:

For projects using a small GNU/Linux system, it’s often important that certain code always be running when the computer is on. You can always log in and start a script running by hand once you turn on the power, but this isn’t very reliable – after all, the power might flicker, or the system might crash for unrelated reasons.

As an example scenario, I have a Raspberry Pi system in charge of logging data from my mousetrap, and I’m about to go on a trip to another continent. The electricity where I live goes out now and then, and I’d like to make sure that my mouse-counting code comes back up on a reboot.

On an Arduino or similar device, the code you write usually just runs shortly after the power comes on, courtesy of a bit of software called a bootloader. Linux systems have these too, but what runs by default is the kernel, which in turn runs something known as an init system that’s in charge of starting all sorts of other software to provide important services.

First, we’ll check out SysV-style init on a Raspberry Pi 2. With roots dating back to early Unix systems, sysvinit was widely used on most Linux distributions until recently, and is still used by the version of Raspbian released in May of 2015, based on Debian Wheezy. It’s also similar to mechanisms still used by the BSD branch of the Unix family tree.

Next, we’ll look at systemd on a BeagleBone Black running Debian Wheezy with systemd. systemd is “a suite of basic building blocks for a Linux system”, recently adopted by most of the major distributions, including Debian Jessie (the current stable release of the project). Eventually, Raspbian will probably run systemd too.

This one just barely scratches the surface of a pretty convoluted topic, and might need extensive updates in future, but hopefully it’s enough to get you going for the simple case. Check it out and let us know what you think.screencast-2015-08-31-18:20:31

[contextly_auto_sidebar id=”LUDCDkJWOX5Lto8Rqzs8aKPWXzNc3XXJ”]


Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 38,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — New Products 11/15/2024 Featuring Adafruit bq25185 USB / DC / Solar Charger with 3.3V Buck Board! (Video)

Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: A New Arduino MicroPython Package Manager, How-Tos and Much More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

Adafruit IoT Monthly — The 2024 Recap Issue!

Maker Business – Adafruit Daily — Apple to build another chip at TSMC Arizona

Electronics – Adafruit Daily — SMT Tip – Stop moving around!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !


No Comments

No comments yet.

Sorry, the comment form is closed at this time.