Be the first to know and get exclusive access to offers by signing up for our mailing list(s).

Subscribe

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 systemd timers, 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 if statements to check if commands like fortune exist 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

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.

Working on something worth sharing? Write for us.

Contribute to We ❤️ Open Source

Help educate our community by contributing a blog post, tutorial, or how-to.

Two World-class Events

If you didn't make it to All Things AI, check out the event summary, and make plans to join us October 19-20 for All Things Open.

Open Source Meetups

We host some of the most active open source meetups in the U.S. Get more info and RSVP to an upcoming event.