Meshtastic Cron Jobs
On October 1, 2025, Mountain Mesh will migrate to MediumFast. As part of that, we wanted to notify users on a somewhat regular basis of the migration. We decided that the easiest way to do that would be a cron job. Something simple that broadcasts a message every 4 hours between 7 am and 7 pm.
Making a shell script to send the message is the easy part. The hard part is getting the environments sorted and running as the correct user.
Installing Dependencies
Make sure to install the Meshtastic CLI before continuing. I did this using pipx. I like pipx because it can install it for an entire user instead of requiring a virtual environment. You can also use things like regular old pip, uv, or poetry.
Here's how to install the dependencies with pipx:
sudo apt update && sudo apt install pipx -y
pipx install meshtastic
pipx ensurepath
Pipx will install the Meshtastic CLI into a local bin for your user. You will need to grab something for later though; the full path of the installed dependency. I had tons of issues with cron not being able to find the proper dependencies. I think it's because when you're logged in as a user, you have your environment loaded from the .zshrc file. I think this is something cron doesn't have access to by default.
To get the full path of the installed Meshtastic CLI, run the following:
which meshtastic
This command will output the directory of where the system has installed the CLI depdendencies. My output was /home/{username}/.local/bin/meshtastic, but yours may vary. Keep note of this path as you'll need this later.
Writing the Shell Script
When setting up a cron, it's best to start from the bottom and work upwards. Start by writing a shell script that you can test at any time to make sure all is behaving properly.
Here's the bash script I wrote up to send the notification:
/home/{username}/.local/bin/meshtastic --sendtext "This node is migrating from LongFast to MediumFast on Oct 1. For more information, see https://mtnme.sh/mediumfast/" --ack
Take note of the first part. That's the output from the which meshtastic command we ran earlier.
I saved this command to a file named notify.sh and did a chmod +x ./notify.sh once I was done writing it to allow for code execution. To execute the command, all I have to do is ./notify.sh from the command line.
Once I am confident the command is working, I move to the next step.
Setting up Cron
There are 2 main profiles for crontab; user-specific and root. Root runs at the system level regardless of user. User-specific runs at the user level. Shocker, I know.
For this instance, we will want to run at the user level. To modify the user-specific cron jobs, run crontab -e.
That command will open up an editor page. Here is what I added to the bottom of the cron job file:
0 7,11,15,19 * * * /usr/bin/zsh /home/user/notify.sh >> /home/user/notify.log 2>&1
As you can see, I am using zsh as my shell. You're welcome to swap that out for your own shell environment such as /bin/bash. Just run which {bash,zsh,sh} to figure out that path. This step might not be totally necessary to be honest. I just am documenting how I got it working.
Also note the >> command. This tells the cron job to take the response of the shell script and append the output to a log file, notify.log, for me to review later. This is great for diagnosing issues down the road.
That's It!
Now I have a cron job running every 4 hours to notify users of the pending network change. Easy stuff, just with a few weird gotchas.
That said, use your powers for good and not evil. Don't flood the mesh.
The benefits of this setup is that you don't need some fancy Python script or a database or any of that nonsense. Just a shell script that runs on a schedule. You could totally add more to the bash script if you like, but "if it ain't broke, don't fix it."