DEV Community

Anguishe
Anguishe

Posted on • Originally published at bashsnippets.xyz

I got tired of deploying broken cronjobs, so I built a tool that generates them properly

Every linux user has a story. Mine is a backup script that silently failed for three weeks because the cron expression was right but the PATH wasn't set, so the script couldn't find tar. Backups looked like they were running. Nothing was actually being archived. I found out when I needed to restore a file.

That specific failure mode — cron jobs that pass silently but don't actually do anything — is one of the most annoying problems in Linux automation because there's no obvious error. The job runs. The exit code is 0. Your logs say nothing because you didn't add logging. And now you're debugging something that happened at 2am three weeks ago.

So I built a tool.


What it does

The Cron Job Builder at bashsnippets.xyz does three things that I always forget to do manually:

1. Builds the expression visually

You pick minute, hour, day of month, month, and day of week from dropdowns. It assembles the expression in real time. There are also quick presets — daily 2am, every 6 hours, weekdays 9am, monthly, every 15 minutes — for the schedules you actually use 90% of the time.

2. Wraps it in production-safe bash

This is the part that actually matters. The tool adds:

  • >> /var/log/cronjob.log 2>&1 — so stdout and stderr go somewhere you can read them later
  • SHELL=/bin/bash — because cron's default shell is not what you think it is
  • PATH=/usr/local/bin:/usr/bin:/bin — this is the one that burned me. Cron has a stripped-down PATH. Commands that work in your terminal fail silently in cron because the binary isn't in scope.
  • MAILTO=you@example.com — optional, but useful for catching failures you're not watching for
  • Lock file via flock — prevents a slow job from stacking on top of itself if it runs longer than the schedule interval

Every single one of these is a checkbox. You don't have to remember them — you just check what you need.

3. Shows the next 10 scheduled run times

So you can verify the expression is actually doing what you think it's doing before you paste it into crontab.


You can also inject a snippet from the library

The tool has a dropdown that lets you pull in a pre-built script from the BashSnippets library — file backup, disk space warning, delete old logs — and have it wrapped in the boilerplate automatically. So you go from "I want to back up my home directory nightly" to a full, copy-ready crontab entry in about 20 seconds.


Why I built this on a static site

The whole site is GitHub Pages. No backend, no database, no server-side anything. The cron expression parser, the next-run-time calculator, all of it runs in the browser. That means it loads fast, works offline if you've cached it, and I don't have to pay for compute just so someone can build a cron expression.


Try it: https://bashsnippets.xyz/tools/cron-job-builder.html

Everything on BashSnippets is free. No login, no email capture, no limit on how many times you use it. Just open it, configure it, copy the output.

If you've ever had a cronjob fail silently and had to debug it at an awkward hour, this is for you.

Top comments (0)