Personal tools
You are here: Home Wiki Cron
Views

My linux system puts the manpage for the crontab file in section five. So you'd read the manpage for the file by typing:

 % man 5 crontab

(On my Solaris machine, the manpage for the command and for the file are the same.)

However, looking up the format each time is tiresome and tedious, and if you don't edit your crontab every day, you're apt to forget the format. Since you can put comments in your crontab file, you can put a little reminder comment to help you when you edit crontab files. I suggest something like this at the top of each crontab file:

 # <min> <hr> <dom> <moy> <dow> command
 #   |    |     |     |     |
 #   |    |     |     |     +-- day of week, 0-6, 0  sunday
 #   |    |     |     +-------- month of year, 1-12, 1  january
 #   |    |     +-------------- day of month, 1-31
 #   |    +-------------------- hour of day, 0-23, 0  midnight
 #   +------------------------- minute of hour, 0-59
 #

Be sure to read the manpage and adjust the comments to reflect any idiosyncratic variations in the actual version of crontab you have installed.

The crontab program

Of course, this is a file that's pretty easy to get wrong, plus it's located somewhere on the system that the user probably doesn't want to know about. So there's a program that knows where the crontab files are kept, and it knows what they are supposed to look like, so it can check the format before actually making any changes.

You edit your crontab file by using the crontab program with an -e (edit) argument:

   % crontab -e

If you have the appropriate permissions (e.g. you've Su'd to root), you can edit someone else's crontab by specifying their account name after the -e, like so:

   # crontab -e someotheruser

The crontab program will look at your EDITOR environment variable and try to use the program specified to edit a copy of your crontab. When you save and quit, the crontab program will verify that your new crontab file looks sane, and then copy it to where it needs to be.

Some versions of vim do not play nice with crontab. Be aware. If you aren't totally repulsed by emacs, you can use it instead of vim. Otherwise you might want to keep vi or a vi-clone installed on your system in addition to vim.

On my linux box, the manpage for the crontab program is in section 1:

 % man 1 crontab

Vixie Cron (the cron that comes on nearly all Linux distros) has several useful options, which are only documented on Debian (as far as I know).



Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: