We ❤️ Open Source
A community education resource
Replace Neofetch with your own Linux MOTD system
How to build an automated message of the day using Bash scripts, systemd services, and timers.
Logging into a server and immediately seeing system information beats running commands manually to check what’s running. In this video from Learn Linux TV, you’ll learn how to build a custom message of the day system that displays hostname, OS, kernel, architecture, and even an optional joke using only tools built into Linux.
Jay walks through creating a complete message of the day (MOTD) system from scratch, teaching essential Linux concepts along the way. The project involves writing a Bash script that uses hostnamectl to gather system information and printf to format it into /etc/motd, the file that displays text when you log in.
The tutorial goes deeper by automating the whole process with systemd. Jay creates a systemd service that runs the script, then builds a systemd timer that triggers the service every hour (configurable to your preference). He explains critical details like why the service should be disabled while the timer is enabled, how OnBootSec delays initial execution to avoid conflicts with startup scripts, and why the service and timer filenames must match for systemd to link them correctly.
As a bonus, Jay demonstrates adding a “joke of the day” feature using the fortune command. The script checks if fortune is installed before attempting to use it, so the feature remains optional. If installed, it appends a random short joke to your MOTD file, making server logins slightly more entertaining.
Key takeaways
- systemd timers replace cron for scheduled tasks – Creating a timer that triggers a service gives you more control and better logging than traditional cron jobs for recurring automation.
- Enable the timer, not the service – When using
systemdtimers, enable the timer to start at boot but leave the service disabled, since the timer will handle starting the service automatically. - Script defensively with conditional checks – Using
ifstatements to check if commands likefortuneexist before running them prevents errors and keeps optional features truly optional.
This hands-on lab delivers practical value while teaching you how systemd services, timers, and Bash scripting work together. Jay’s step-by-step approach makes the complexity manageable even if you’ve never created systemd units before.
More from Learn Linux TV
- youtube.com/learnlinuxtv
- Linux tips | Linux how-to’s | Linux installation guides
- Stop feeling guilty about Linux distro hopping
- Getting started with COSMIC desktop tiling
- 10 tips to learn Linux easier and faster
The opinions expressed on this website are those of each author, not of the author's employer or All Things Open/We Love Open Source.