My favorite open source tool for using crontab

Crontab-ui is a web frontend written in Node.js that helps manage the crontab file.
3 readers like this
3 readers like this

Automation is a hot topic right now. In my day job as a site reliability engineer (SRE), part of my remit is to automate as many repeating tasks as possible. But how many of do that in our daily, not-work, lives? This year, I am focused on automating away the toil so that we can focus on the things that are important.

One of the earliest things I learned about as a fledgling systems administrator was cron. Cron is used far and wide to do things like rotate logs, start and stop services, run utility jobs, and more. It is available on almost all Unix and Linux systems, and is something every sysadmin I know uses to help manage services and servers. Cron can run any console application or script automatically, which makes it very, very flexible.

Image of a Crontab

(Kevin Sonney, CC BY-SA 4.0)

I have used cron to fetch email, run filtering programs, make sure a service is running, interact with online games like Habitica, and a lot more.

Using cron the traditional way

To get started with cron, you can simply type crontab -e at the command line to open up an editor with the current crontab (or “cron table”) file for yourself (if you do this as root, you get the system crontab). This is where the job schedule is kept, along with when to run things. David Both has written extensively on the format of the file and how to use it, so I'm not going to cover that here. What I am going to say is that for new users, it can be a bit scary, and getting the timing set up is a bit of a pain.

Introducing crontab-ui

There are some fantastic tools out there to help with this. My favorite is crontab-ui, a web frontend written in Node.js that helps manage the crontab file. To install and start crontab-ui for personal use, I used the following commands.

# Make a backup
crontab -l > $HOME/crontab-backup
# Install Crontab UI
npm install -g crontab-ui
# Make a local database directory
mkdir $HOME/crontab-ui
# Start crontab-ui
CRON_DB_PATH=$HOME/crontab-ui crontab-ui

Once this is done, simply point your web browser at http://localhost:8000 and you'll get the crontab-ui web interface. The first thing to do is click “Get from Crontab” to load any existing jobs you may have. Then click Backup so that you can roll back any changes you make from here on out.

 

Image of Crontab-UI

(Kevin Sonney, CC BY-SA 4.0)

 

Adding and editing cron jobs is very simple. Add a name, the full command you want to run, and the time (using cron syntax), and save. As a bonus, you can also capture logs, and set up the mailing of job status to your email of choice.

When you're finished, click Save to Crontab.

I personally really love the logging feature. With crontab-ui, you can view logs at the click of a button, which is useful when troubleshooting.

One thing I do recommend is to not run crontab-ui all the time, at least not publically. While it does have some basic authentication abilities, it really shouldn't be exposed outside your local machine. I don't need to edit my cron jobs frequently (anymore), so I start and stop it on demand.

Try crontab-ui the next time you need to edit your crontab!

Kevin Sonney is a technology professional, media producer, and podcaster. A Linux Sysadmin and Open Source advocate, Kevin has over 25 years in the IT industry, with over 15 years in Open Source. He currently works as an SRE at elastic.

3 Comments

That's a nice looking program! But I still prefer using "vcron" which I have used for many years. You can get it at the following site if you want to check it out. It's written in Tcl/Tk and is simply a script file you put on your path.

http://daniel.roche.free.fr/vcron/vcronGB.html

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.