7 Useful Cron Alternatives For Linux

Cron Alternatives Featured Image

For those who are familiar with the Unix system, you will also be familiar with the cron application that allows you to schedule and automate tasks to run on their own. We even have tutorials that show you how to get started with cron and crontabs. However, cron is not perfect, as it requires your system to be running 24 hours a day. If you have a habit of turning off your computer at night, and a cron job is scheduled in the sleeping hours, the task won’t be executed. Luckily, there are several cron alternatives that can do a better job than cron. Let’s check them out.

1. Anacron

Anacron is a periodic command scheduler just like cron. The only difference is that it does not need your computer to be always running. You can schedule your task to run at any time. When your computer is off, the task will be executed the next time you turn the computer on.

To get started, simply install anacron in your system. It is available in most package managers. Use the following command to install in Ubuntu:

sudo apt install anacron

Anacron works similar to cron. You can add your job to the /etc/anacrontab file.

The syntax to add a job is

period   delay-after-computer-start   job-identifier   command

For example, to run a backup script everyday, you can add the following command:

1   15    cron.daily     /bin/sh /home/ramces/backup.sh

The disadvantage of anacron is that it only deals with tasks on a daily, weekly or monthly schedule. You can’t use it for a hourly or minutes schedule.

2. Cronie

Another brilliant cron alternative that you can install today is Cronie. Unlike the previous entries, Cronie is a small suite of software that aims to provide a complete cron experience. In order to do that, Cronie includes the anacron package by default. This means that cronie can provide both synchronous and asynchronous job scheduling out of the box.

Cron Alternatives Cronie Webpage

Further, installing cronie is relatively straightforward. First, you need to obtain the program’s source code from their Github page:

wget https://github.com/cronie-crond/cronie/releases/download/cronie-1.6.1/cronie-1.6.1.tar.gz
Cron Alternatives Download Cronie Tar

Once done, unpack the archive by running tar on the terminal:

cd Downloads
tar xvzf cronie-1.6.1.tar.gz

From there, go inside the Cronie directory and compile the program’s source code:

cd cronie-1.6.1/
sudo make install
Cron Alternatives Cronie Compile

Once done, you can now use Cronie to manage the cron jobs in your machine. Similar to anacron and cron, you can create a cron job by running crontab -e. This will allow you to edit your specific user’s crontab. Knowing that, Cronie also follows the standard format:

* * * * 0 /your/command/here

3. fcron

Fcron is the best of both cron and anacron. It doesn’t require your computer to be running 24×7, and it can work with tasks on an hourly or minute basis.

The only way to install Fcron is to download the source file and compile it yourself.

  1. Download the source file here.
  2. Extract the archive. Open a terminal and change the filepath to the extracted archive folder.
  3. Run the following commands:
sudo make install

It will ask you a few questions during the installation and you can safely answer “y” (yes) for all of them.

To start creating a fcron job, simply type fcron -e in the terminal.

Cron Alternatives Sample Crontab

The syntax for fcron is similar to cron:

minute  hour  day-of-month  month  day-of-week  command-to-be-executed

and it comes with more options than cron, such as setting up a task to run between a time range.

For those who prefer a GUI, you can check out fcronq

4. bcron

Bcron is a simple and modern alternative to the standard cron program. Similar to Cronie, bcron aims to provide a suite of software that manages your system’s job scheduling. It does this by separating all of the component functions of cron into their own respective programs. This, in turn, allows bcron to be both highly modular and secure.

Cron Alternatives Bcron Webpage

With that, installing bcron is incredibly easy. In that, if you are using Debian or Ubuntu you can install the program through apt:

sudo apt install bcron
Cron Alternatives Bcron Install

Once done, you can now use bcron to schedule tasks in your system. In order to do that, you need to first run the following command to enable the program:

envdir /etc/bcron bcron-start
envdir /etc/bcron bcron-update /etc/crontab /etc/cron.d

The first command will start bcron in your system while the second one will tell bcron to open and update both the crontab and cron.d files. From there, the syntax of creating a new task is similar to both anacron and cronie. For example, I can write the following line to tell bcron to run my script every 5 AM on the 1st of every month:

0 5 1 * * /my/monthly/script.sh

5. Hcron

Hcron is relatively unknown, but that does not make it less useful. In fact, it comes with several features that make it unique. For example, you can easily label and organize your cron type jobs, manage a network of computers and your users’ crontab files, beck up easily, and version control your cron type jobs.

To install hcron, download the .deb file (or .rpm file, depending on your Linux system) and install it in your system.

Hcron stores each event as a plain text file. To get started, simply create a text file with the command:

hcron-event /path/to/event-file.txt

In the text editor that opens, you can fill in the details of the event.

Cron Alternatives Sample Hcron File

There are many more things that you can do with hcron and it is advisable to download the user guide to have a better understanding of how it works.

6. Jobber

Jobber is a task scheduler written in GO and is a more powerful tool than cron. It features job execution history with status, controlling whether and when a job is run again after it fails and getting notified on each failed run or only about jobs that were disabled due to repeated failures.

To install Jobber, you have to make sure that GO is installed in your system. Next, type the commands:

cd /path/to/your/go/workspace
go get github.com/dshearer/jobber
make -C src/github.com/dshearer/jobber

After the installation, start Jobber with the command:

sudo /usr/local/sbin/jobberd start

To create jobs, create a file named “.jobber” in your home directory and add the job in the following format:

- name: #Enter the job name here
  cmd: #the command to run
  time: #as the same as cron format
  onError: #Stop | Backoff | Continue
  notifyOnError: #false | true
  notifyOnFailure: #false | true

As you can see from the format, it allows you to define the actions to take when it has errors (“Stop”, “Backoff” or “Continue”) and whether it should notify you when it fails.

Once you have updated the job list, use jobber reload to get Jobber to reload the new list.

At any time, you can use jobber log to see a list of recent runs of any jobs.

7. mcron

Mcron is a fast and innovative task scheduling program for Linux. Similar to the programs above, mcron aims to provide you with a simple way to manage the scripts and programs that you want to run in your system. Unlike the programs above, mcron also aims to redefine task scheduling by reconstructing cron jobs from scratch.

Cron Alternatives Mcron Webpage

With that, installing mcron is incredibly simple. It is available in both Debian and Ubuntu and you can easily obtain it by running the following:

sudo apt install mcron
Cron Alternatives Mcron Install

Once done, you can now start using mcron as your scheduler. To do that, you need to first create the directory where mcron will look for its tasks:

mkdir /home/$USER/.config/
touch /home/$USER/.config/cron

From there, you can now edit this cron file to contain all of the jobs that you want mcron to do. Unlike the programs above, mcron uses an alternative syntax for scheduling:

(job '(type '(range)) "command")
  • The job function tells mcron that this line of Lisp contains a task that it needs to schedule.
  • The type and range are lists that hold the timing information for mcron. In that, the type controls the scale that mcron will operate on while the range determines the time interval for that scale.
  • Lastly, the command is a string that tells mcron which command or program it needs to run.

With that, I can then write the following to my .config/cron file to run my script once an hour for three hours a day:

(job '(next-hour '(1 4 8)) "my-script.sh")

Frequently Asked Questions

Is it possible to use the regular cron syntax with mcron?

Aside from being an innovative task scheduler, mcron also aims to be backwards compatible to the older cron syntax. As such, you can also use a crontab-like syntax for your .config/cron file. For example, I can write the following line to tell mcron that I want to run my script once a day by midnight:

0 0 0 * * /path/to/my/script.sh

One important thing to note, however, is that writing your scheduled tasks this way will not allow you to use mcron’s more extensive and flexible features.

Is it possible to stop cron from sending mail to my user account?

It is possible to stop cron from sending any system mail to your user. In order to do that, you will need to edit your crontab and provide a MAILTO variable with a value of nobody. For example, this is an excerpt of a crontab where I have disabled the system mail:

* * 1 * * /first/script/here.sh
0 0 * * * /second/script/here.sh

Knowing that, you can also use this syntax to redirect another user’s crontab output to a different user. For example, you can easily set this variable on the root user’s crontab to get the output from all of the scheduled tasks that it is running.

Which is the best cron alternative for me?

While this is a highly subjective question, a good cron alternative should be able to do everything that you might need for your specific use case. For example, you might want to consider using simpler task schedulers such as anacron and cronie if you only plan to use cron for the occasional basic task.

On the other hand, a more flexible and powerful task scheduler such as mcron will allow you to script and define the behavior of cron itself. However, using mcron for even basic tasks can be daunting for the uninitiated beginner.

Image credit: Unsplash

Ramces Red
Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox