How To Create A Cron Job?

By Greg Keller Posted May 7, 2015

Cron Job

As IT folks know, cron can be time-consuming, cumbersome, and painful.

But the functionality of cron is still so important to any organization. As a time-based job-scheduler, cron allows you schedule jobs (commands or shell scripts) to occur automatically at periodic intervals. You need to set up recurring tasks on your server infrastructure often. You need to rotate logs, package up data, and do any number of other tasks on your servers.

So how do you create a cron job efficiently and effectively? That’s a trick question. You don’t.

What’s Wrong with Cron?

If cron feels outdated to you, that’s because it is.

Cron is a 40 year old utility that was created to execute recurring tasks. At the time cron was created, it was written by computer scientists for computer scientists. Cron’s format was created to be as expressive as possible and as compact as possible. In a lot of ways from a technical perspective the original cron format was ingenious for the time.

40 years later, the population of users has changed. Not everybody understands computers down to assembly language. In fact, that is a good thing. The technology industry has built tremendous abstractions that allow IT professionals to focus on higher order problems. But while technology as a whole has evolved rapidly, cron has been a chronic underachiever, lagging behind.

Unfortunately, cron is still a staple. The value it brings is tremendous and it is likely used in just about every industry and perhaps on just about every server. Over time, cron has received just enough updates to stay relevant and in use.

Where Cron Falls Short

How do you create and manage cron jobs across a server fleet? Cron isn’t a centralized utility that rolls up each job on each server for a centralized view. Instead it is not only dependent on each server, but also by each user. There aren’t any checks and balances with cron. Cron jobs from one user can easily conflict with jobs from another user on the same system.

Also, if for some reason the cron daemon fails, there is no redundancy, notification, or error handling. You are just out of luck for whatever the task was that you wanted executed.

Modern Alternatives to Cron?

It turns out there is a better way to handle recurring jobs. You can use JumpCloud’s Directory-as-a-Service command execution capabilities.

We’ve built a cross-platform capability to execute tasks in whatever language you want (as long as your device supports it). Tasks can be set on a recurring schedule, executed ad hoc, or triggered by external events. You’ll get a full run-down of whether the job was executed, any error codes, and full logging.

Best of all, you have a simple interface to schedule tasks, view tasks across users, and see the entire fleet’s jobs from one console. JumpCloud’s command execution capabilities give you an straightforward, modern approach to recurring tasks.

If you would like to try out JumpCloud’s command execution capabilities, you can sign-up for a free account and test the solution’s capabilities.

Greg Keller

Greg is JumpCloud's Chief Product Officer, overseeing the product management team, product vision and go-to-market execution for the company's Directory-as-a-Service offering. The SaaS-based platform re-imagines Active Directory and LDAP for the cloud era, securely connecting and managing employees, their devices and IT applications.

Recent Posts