Run cron job every 90 mins (minutes) – Linux Scheduling, Batch Automation, Scheduled Jobs

By | July 4, 2015
Run a cron job every 90 mins (minutes)

Run a cron job every 90 mins (minutes)

Run cron job every 90 mins

Running a cron job is normally easy enough when you do not try and get over-complicated. Every hour or minute, or even every Monday is a simple task using the standard columns included in cron.

Just to refresh you here are the first columns of a standard crontab for reference :

field allowed values
—– ————–
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

But to run cron job every 90 mins (minutes) needs just a little bit of thought. Firstly, you might be thinking WHY would you ever want to run a cron task every 90mins?? Well every persons use of cron is different, but one example could be a football game that lasts 90minutes. How you put that to some use depends on the workings of your system!

I worked this out simply by writing the times I wanted the task to run down like this :


From that you can see a pattern forming. Of course you could list individual times for a whole day, but thats HORRIBLE, therefore the shortest way is across 2 lines like this :

# Run cron job every 90 mins
# 1st line will run at 00:00, 03:00, 06:00 hours etc. 2nd line will run at 01:30, 04:30, 07:30 etc
00 0-21/3 * * * /home/task1.bash > /dev/null 2>&1
30 1-22/3 * * * /home/task1.bash > /dev/null 2>&1

So as you can see from the explanation line, the control is in the pattern, and working out the gaps between the hours for each run.

Check out -  Install and configure Varnish 4 - Varnish Cache for Wordpress

Hope that saves you some minutes instead of working it out yourself!

Cron definition and description (see full man page HERE) :

A crontab file contains instructions to the cron daemon of the general form: “run this command at this time on this date”. Each user has their own crontab, and commands in any given crontab will be executed as the user who owns the crontab.

Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. Note that comments are not allowed on the same line as cron commands, since they will be taken to be part of the command. Similarly, com-ments are not allowed on the same line as environment variable settings.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.