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 […]
  • Change main hostname and IP of WHM/cPanel machineChange main hostname and IP of WHM/cPanel machine One thing you’ll probably run into sometime is changing the hostname and IP address of a cPanel machine.. whether you’re cloning it for a quick start or if you’ve taken it over.. moving it […]
  • Keep your WordPress site secure!Keep your WordPress site secure! I work for a hosting company. On average, I’ll clean up at least 3-4 WordPress sites each month for our clients. Most of the time, they’re running on old versions of WordPress and have […]
  • Add time and date to your bash historyAdd time and date to your bash history Often, you’ll go looking for a shell command that you used in the past – you can remember around when you did it but of course that won’t help you because by default the bash history won’t […]
  • Migrate mail from one server to another with imapsyncMigrate mail from one server to another with imapsync Have you been in the situation where you needed to move everyone’s mail from one provider to another?  It’s a pain to do using the mail client one at a time, but with this guide, you’ll be […]

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=""> 

*