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.
Have an amazing project to share? Join the SHOW-AND-TELL every Wednesday night at 7:30pm ET on Google+ Hangouts.
Join us every Wednesday night at 8pm ET for Ask an Engineer!
Learn resistor values with Mho’s Resistance or get the best electronics calculator for engineers “Circuit Playground” – Adafruit’s Apps!
Maker Business — TechShop is closed, files bankruptcy
Wearables — Get concrete solutions
Electronics — Are you grounded?
Biohacking — Learning to See with Sound
No comments yet.
Sorry, the comment form is closed at this time.