Scheduling Linux tasks isn't a new idea, but as I was creating a quick cron entry on my hotspot, it occurred to me that there may be some hams out there who aren't familiar with the process.
My objective was to have my hotspot connect to the "East Coast Reflector's (ECR)" YSF room each morning at 7am (eastern) for "The Morning Brew" radio net. My hotspot is running WPSD, which is a fork of the typical PiStar OS. This same concept should work on a PiStar hotspot, however, using the pi-star equivalent commands.
There are two common methods for scheduling a task on a modern linux machine, Systemd's "Timer" units and Cron. My preference in most cases is to use systemd, which is more modern and feature-rich, but cron has the benefit of being quicker to create. For this simple task, I felt cron was the right approach.
Cron works by reading a "cron table" generally referred to as a "crontab."
The commands I want to run require root privileges, so I will edit root's crontab with the command "sudo" (do as root, aka SuperUser) followed by "crontab" with the edit argument: sudo contab -e
Crontabs uses five fields to define a date/time, followed by the commands (known as a "job") to run at the specified time.
The five fields are minute, hour, day of the month, month, day of the week. A *
is used to indicate that the job should run on "every", so a *
for the day of the month would mean "every day of the month."
Here's my crontab:
0 7 * * MON-FRI wpsd-ysflink unlink && wpsd-ysflink ysf44444
0 9 * * MON-FRI wpsd-ysflink unlink
To break it down, the first line will run at 0 minutes, on the 7th hour (7am), on every day of the month, during every month, on the days of the week from Monday to Friday.
The command wpsd-ysflink unlink && wpsd-ysflink ysf44444
is actually two commands together: wpsd-ysflink unlink
which will disconnect the hotspot from any current reflector, and wpsd-ysflink ysf44444
which will connect it to reflector ysf44444, which is part of ECR.
Then, at 9am, it will disconnect from the reflector.
Of course, this doesn't help me remember to actually turn my radio on, but that's on me.