Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

The first noncomment line in a legacy crontab file begins with five asterisks:

* * * * * ([a_command]) >/dev/null 2>&1

The authors are gone, so I do not know their intent. What does all-wildcards mean to (Solaris 8) cron? The betting here is either run once, run continuously, or run never, which is unfortunately broad.

If you are wondering about the comment line preceding this, it is "Do not delete."

Note: This cron file is working. This question is not a duplicate of a question about broken cron files or cron files which require troubleshooting.

share|improve this question

marked as duplicate by Jenny D, mdpc, DKNUCKLES, Ladadadada, HBruijn Jun 6 at 10:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
Something else to note, since it tripped me up severely at work recently: the >/dev/null 2>&1 section feeds all output from STDOUT and STDERR to /dev/null. The reason this is done: If you don't, then output from the program called in crontab will be mailed to the local mailbox of the user. Before I knew this I filled up a hard drive on a production server from a script running every two minutes. –  Luke has no name Jul 24 '10 at 7:16
    
Thanks, Luke has no name; I had mis-attributed it to over-fussiness. –  Thomas L Holaday Aug 18 '10 at 19:36
    
It looks like it qualifies to me. The answer explains how crontab works, and as it explains, this would run once every minute. The marking as duplicate is not meant to disparage your question, but to collect the commonly asked questions about cron, and their answers, in a single place. –  Michael Hampton Jun 11 at 0:20
add comment

3 Answers 3

up vote 26 down vote accepted

Every minute of every day of every week of every month, that command runs.

man 5 crontab has the documentation of this. If you just just type man crontab you get the documentation for the crontab command. What you want is section 5 of the manual pages which covers system configuration files including the /etc/crontab file. For future reference, the sections are described in man man:

   1   Executable programs or shell commands
   2   System calls (functions provided by the kernel)
   3   Library calls (functions within program libraries)
   4   Special files (usually found in /dev)
   5   File formats and conventions eg /etc/passwd
   6   Games
   7   Miscellaneous  (including  macro  packages and conven‐
       tions), e.g. man(7), groff(7)
   8   System administration commands (usually only for root)
   9   Kernel routines [Non standard]
share|improve this answer
    
That's the literal meaning; I was worried that it might be a special case. Thanks for the reassurance. –  Thomas L Holaday Jul 20 '10 at 21:19
5  
+1 for the answer, -1 for the man cron comment. man pages are notoriously hard to read and understand for the beginner - that's why people come here, to have the man pages explained to them. –  Mark Henderson Jul 20 '10 at 21:25
4  
Totally, because it should have been man 5 crontab. That manpage is more specific and very easy to understand. See: linux.die.net/man/5/crontab –  Warner Jul 20 '10 at 21:34
5  
That's fine, provided the user is aware that the 5 is even relevant. Most new or part time Linux users don't know what number, if any, to use to access man pages. –  John Gardeniers Jul 20 '10 at 21:43
2  
@John, to prove your point, as someone who only dips their toe into *nix when I need to restart the occasional apache server, I was not even aware you could do a man 5 and I have no idea what would happen if I did... –  Mark Henderson Jul 21 '10 at 3:19
show 5 more comments
First star = Minutes: 0-59
Second star = Hours: 0-23
Third star = Day of Month: 0 - 31
Fourth star = Month: 0 - 12
Fifth star = Day of Week: 0 - 6 (0 means sunday)

Say you want to run something every 1st of every month.

0 0 1 * * something.sh
share|improve this answer
1  
That means to run something every minute of every hour on the 1st of every month (that would be 1440 times on day 1). –  Kevin Brock Jul 21 '10 at 4:41
    
Oh yeah, let me edit that. –  Michael Burns Jul 21 '10 at 18:37
add comment

* = always. It is a wildcard for every part of the cron schedule expression.

So * * * * * means every minute of every hour of every day of every month and every day of the week.

 * * * * *  command to execute
 ┬ ┬ ┬ ┬ ┬
 │ │ │ │ │
 │ │ │ │ │
 │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
 │ │ │ └────────── month (1 - 12)
 │ │ └─────────────── day of month (1 - 31)
 │ └──────────────────── hour (0 - 23)
 └───────────────────────── min (0 - 59)

The nice drawing above is provided by wikipedia

An other example:

0 * * * * -this means the cron will run always when the minutes are 0 (so hourly)
0 1 * * * - this means the cron will run always at 1 o'clock.
* 1 * * * - this means the cron will run each minute when the hour is 1. So 1:00, 1:01, ...1:59.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.