Understanding cron job times

Rob —  July 24, 2014 — 2 Comments

Often, you’ll want to use cron to schedule daily, weekly, hourly (etc…) tasks on your linux system(s). cPanel has a little GUI for it, but since I don’t trust GUIs very often, I like just doing it the ‘old fashioned’ way. This little guide will hopefully help you to figure out cron once and for all.

Ok, so cron is what is used on your Linux system to schedule repeating events. It’s used to rotate logs, run clean-up scripts, and anything else you can think of that you’d want to schedule.

To view your crontab (view the current cron jobs for your user) simply type in:

To edit your crontab (edit the current cron jobs for your user) type in:

If you are root and you want to edit another user’s crontab, you can specify them like:

A typical cron entry looks like this:

Let’s break this down. There are 5 fields before the actual command:
From the man page:

For ‘month’ or ‘day of week’, you can use the first 3 letters – case doesn’t matter.. ie: sun, mon, tues… or jan, feb, mar.. etc..

Then, you’ll see the command – in this case, it’s a mysql backup script.

Let’s run through a couple examples:

Run a command once/week scheduled Saturday morning at 6am:

or

Now, let’s only run it on Saturdays in August:

How about every 5 minutes all the time:

How about every other day at 10am!

Hopefully, this will help clear up any confusion you’ve had with cron! Let us know below!

Related posts from Linux Brigade!

  • Manually run ClamAV on cPanel and check every userManually run ClamAV on cPanel and check every user If you’re running WHM/cpanel and want to run a scan on every user manually, perhaps when first installing ClamAV, you’ll want to run this command which is endorsed by cPanel […]
  • Rescued my little Acer C7 ChromebookRescued my little Acer C7 Chromebook After installing chrubuntu on my c7, I decided to put it back to factory and give crouton a try so that I could run both chrome and crouton at the same time.  I created the restore usb […]
  • Turn off unneeded services on your Linux machineTurn off unneeded services on your Linux machine One of the easiest ways to start securing your server (and speeding it up) is to turn off unnecessary services that are usually running by default. This little script will go through and […]
  • CentOS 7 / RHEL 7 – Open portsCentOS 7 / RHEL 7 – Open ports One of the most common things I do on Linux machines is open ports to test software in a development environment.  In the past, that meant trying to remember (and Googling) cryptic […]
  • Search previous commands typedSearch previous commands typed If you want to see a collection of your previous commands used in Linux, you can always type ‘history’ for a listing of them. You can even search through history by grepping for the […]

2 responses to Understanding cron job times

  1. For some of the users, they don’t have cron on server, or the server limits the cron use. In those cases, EasyCron is an option. To those who don’t know how to use crontab, EasyCron is a great alternative 🙂

Trackbacks and Pingbacks:

  1. Delete cPanel account error_log files | Linux BrigadeDelete cPanel account error_log files - July 24, 2014

    […] suggest that you schedule a cron job to clear them out weekly.. like, let’s clear them out every friday […]

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

*