Cron is a time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates.

learn more… | top users | synonyms (2)

112
votes
9answers
120k views

When does `cron.daily` run?

When do entries in cron.daily (and .weekly and .hourly) run, and is it configurable? I haven't found a definitive answer to this, and am hoping there is one. I'm running RHEL5 and CentOS 4, but for ...
101
votes
4answers
136k views

Why is my crontab not working, and how can I troubleshoot it?

This is a Canonical Question about using cron & crontab. The answer for 'Why is my crontab not working, and how can I troubleshoot it?' can be seen below. This addresses the cron system with ...
64
votes
4answers
84k views

Running Cron every 2 hours [duplicate]

I have the cron job as shown below, and wanted it to run every 2 hours, but it keeps running every 2 minutes. Can someone tell me where I'm going wrong? * */2 * * * /path-to-script
48
votes
10answers
113k views

Running a cron job manually and immediately

(I have already read How can I test a new cron script ?.) I have a specific problem (cron job doesn't appear to run, or run properly), but the issue is general: I'd like to debug scripts that are ...
44
votes
7answers
28k views

Prevent duplicate cron jobs running

I have scheduled a cron job to run every minute but sometimes the script takes more than a minute to finish and I don't want the jobs to start "stacking up" over each other. I guess this is a ...
41
votes
4answers
86k views

What is the correct syntax to run cron every 4 hours? [duplicate]

I have the following syntax (which I think is correcT?) but it runs the command every minute! * */4 * * * /cmd.sh
34
votes
5answers
27k views

How to send the output from a cronjob to multiple e-mail addresses?

In the beginning of a crontab file you could use the MAILTO instruction to indicate you want the output to be sent as an e-mail to an e-mail address. I would like to send the output to multiple ...
34
votes
5answers
19k views

Job scheduling using crontab, what will happen when computer is shutdown during that time?

I schedule some tasks using crontab. What will happen if my computer is shutdown or turned off during the time when cron was scheduled to do something? Does each missed cron job run after computer ...
33
votes
7answers
66k views

How to get e-mail from (failed) cron-jobs in Ubuntu?

I create cron-jobs in Ubuntu by placing the executable in one of /etc/cron.{daily,hourly,monthly,weekly}. There are lots of directories starting with cron: kent@rat:~$ ls -ld /etc/cron* drwxr-xr-x 2 ...
32
votes
6answers
14k views

How to Modify a Cronjob Email Subject

I am running a half dozen different cron jobs from my hosting at Hostmonster.com. When a cronjob has been executed I receive an email with the output of the script. The email comes in the format of: ...
29
votes
7answers
19k views

Can I run a cron job more frequently than every minute?

Is it possible to run a cron job every 30 seconds without a sleep command?
29
votes
6answers
94k views

how to create a cron job that runs on the first day of month [duplicate]

There are fields on my server's control panel like this Minute - Hour - Day of month - Month - Day of the week - Command How can i create a cron job runs on first day of the month with this fields ...
28
votes
5answers
29k views

How can I monitor what logrotate is doing?

How can I monitor what logrotate is doing in Ubuntu? Can the activity of logrotate be monitored?
28
votes
6answers
5k views

Outgrowing cron: what's the next scheduler?

We've been using cron for about as long as I can remember to handle all of our job scheduling needs. Everything from storage clones/snapshots to reports against databases to daily system reports to ...
27
votes
2answers
37k views

How to run cron job on a specific hour every day?

What do I need to write in crontab to execute a script at 3pm every day?
27
votes
3answers
17k views

What does * * * * * (five asterisks) in a cron file mean? [duplicate]

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-...
22
votes
2answers
19k views

What user do scripts in the cron folders run as? (i.e. cron.daily, cron.hourly, etc)

If I put a script in /etc/cron.daily on CentOS what user will it run as? Do they all run as root or as the owner?
21
votes
2answers
23k views

How do I edit the crontab of another user on my linux server?

I have a user on my linux server who has sudo. I want to edit the crontab of another user. I'm new to this though and don't understand what the man pages are telling me yet. Man crontab tells me I ...
21
votes
2answers
14k views

Better logging for cronjobs? Send cron output to syslog?

I am looking for a better way to log cronjobs. Most cronjobs tend to spam email or the console, get ignored, or create yet another logfile. In this case, I have a Nagios NSCA script which sends data ...
19
votes
7answers
49k views

How to disable everything in crontab -l?

I just want to pause everything. Don't execute anything listed on crontab -l.
19
votes
4answers
2k views

How precise is a cron daemon?

Is the cron job scheduler really precise? I mean, I need a script to run every night the latest possible, BUT before 00:00 of the next day. I'd ideally run a cron job at 23.59 (or 11:59 pm), but ...
19
votes
2answers
4k views

What's wrong with my cronjob syntax, I'm trying to use a backtick (`)?

Here's what I'd like to automate: 00 08 * * * psql -Uuser database < query.sql | mail somone@null.com -s "query for `date +%Y-%m-%dZ%I:%M`" Here's the error message: /bin/sh: -c: line 0: ...
19
votes
5answers
20k views

How can I prevent cron from filling up my syslog?

I have a script which needs to be executed each minute. The problem is that cron is logging to /var/log/syslog each time it executes. I end up seeing something like this repeated over and over in /...
19
votes
8answers
24k views

How to change “From:” field for emails from Cron?

I use remote SMTP via nullmailer and it requires set From field to the specific name, but cron set it as root@my.sweet.server.com. How could I change it to something like me@ya.ru?
18
votes
4answers
16k views

Cron: Only get errors in emails?

I finally set up a realistic backup schedule on my data through a shell script, which are handled by cron on tight intervals. Unfortunately, I keep getting empty emails each time the CRON has been ...
17
votes
2answers
8k views

escaping double quotes and percent signs (%) in cron

The following command works from prompt but not from crontab. grep abc /var/log/messages | grep "`date '+%B %d'`" | mail -s"abc log of `hostname`" shantanu.oak+`hostname`@gmail.com I need to add ...
17
votes
4answers
74k views

How to save and exit crontab -e?

How to save and exit crontab -e? i tried every method listed here and none works, i have a centos 5, vi comes by default with yum and i installed nano Solved just changed the default editor export ...
17
votes
7answers
17k views

Can cron write job output to a log *by default* (instead of mail)?

We all know the right way to handle output from cron jobs is to redirect it to a file: 0 * * * * /bin/date >> /var/log/date.log 2>&1 However, sometimes admins are lazy, forgetful, or ...
16
votes
2answers
559 views

Is there a utility like cron, that schedules a job for later (but only once)?

I'm trying to design a program that sends a text when a certain (non-periodic) event occurs. Right now, I'd like a script that finds when this event occurs, and then schedules a (cron-like) job that ...
16
votes
2answers
14k views

How to: 1 Cron Job every ODD minutes and 1 other every EVEN minutes?

I have 2 cron jobs, i want one of them to run every odd minute (1,3,5,7,9,11....57,59) and i want the other one to run every even minute (0,2,4,6,8,10,12...58) how can i do it in an easy way? (no ...
16
votes
2answers
8k views

Run command as Linux “system” user (shell = /bin/false)

I created a "system" user in Ubuntu 11.04 (adduser --system) for running certain cron jobs, but sometimes I want to test things out by manually running commands as that user. What's the easiest way to ...
15
votes
3answers
14k views

Crond offset five minute schedule

Is it possible to offset a cron script set to run every 5 minutes? I have two scripts, script 1 collects some data from one database and inserts it into another, script 2 pulls out this data and a ...
15
votes
7answers
9k views

Robustly disabling specific cron.{hourly,daily,weekly} script

On various systems that I administer, there are cron scripts that get run via the commonly-used /etc/cron.{hourly,daily,weekly} layout. What I want to know is whether there's any common 'disable this ...
15
votes
3answers
7k views

Override MAILTO for a single crontab entry

We have a role account at work that has a pretty big crontab. Its MAILTO is pointed at a shared address, so that a number of us get notified if something fails. I'd like to add an entry to this ...
15
votes
10answers
17k views

Techniques to Monitor cron tasks?

Are there good techniques for monitoring cron tasks over a cluster? We're starting to use cron to launch tasks at daily intervals. A few ideas for checking out information: Add special application ...
15
votes
3answers
17k views

Do I need to refresh or restart anything after I add/update a crontab in Ubuntu Server 8.04?

When you change something in Apache you need to reload or restart apache. Does anything need to be refreshed or restarted in Ubuntu Server 8.04 after I add/update the crontab? Thanks a bunch for your ...
15
votes
4answers
14k views

Is there a way to validate /etc/crontab’s format?

I prefer to stick scheduled tasks in /etc/crontab so I can see at a glance what's scheduled to run, regardless of which user the task runs as. The only gotcha is that the format isn't validated on ...
13
votes
2answers
608 views

How does cron handle remainders in “every so often” jobs

If I do this: */9 * * * * /path/to/wotnot At what times will the task run in two hours, starting at 09h00 Is it A: 09h00 09h09 09h18 09h27 09h36 09h45 09h54 10h03 10h12 10h21 10h30 10h39 10h48 ...
13
votes
4answers
907 views

How to schedule server jobs more intelligently than with cron?

I run a job every minute to reindex my site's content. Today, the search engine died, and when I logged in there were hundreds of orphan processes that had been started by cron. Is there another ...
13
votes
5answers
13k views

Execute rsync command over ssh with an ssh agent via crontab

i have a cronjob: 0 9 * * * rsync -a mydir remote_machine: i installed this with 'crontab -e'. i have an ssh-agent running, and when i execute the rsync command itself it works w/o any user ...
13
votes
2answers
2k views

Weird syslog order

Have you ever seen wrong order in /var/log/syslog ? I think that it causes only crontab. Jun 28 22:20:01 alex CRON[2327]: (root) CMD (something > /dev/null) Jun 28 22:21:01 alex CRON[2700]: (root) ...
12
votes
3answers
974 views

Running a cronjob with different parameters each day

I am a programmer, and do not know a lot about crons, but I want to know if this is possible. Lets say I have an array [option1, option2, option3] and a script which I run in NodeJS called script.js. ...
12
votes
6answers
632 views

How to keep cron from stampeding?

Say I have several cron scripts that need to run every 15 minutes. I could set them to run: */15 * * * * , but then they all run at the same time. It seems silly for the server to sit idle for ...
12
votes
3answers
7k views

Why is only one wget command working in my crontab?

I wish to fetch content from a PHP script on my server two times a day, altering a query variable lang to set what language we want, and save this content in two language specific files. This is my ...
12
votes
11answers
4k views

Is it safe to run apt-get update every night?

Is it safe to run apt-get update -y through cron on a production server?
12
votes
4answers
23k views

Sending cron output to a file with a timestamp in its name

I have a crontab like this on a LAMP setup: 0 0 * * * /some/path/to/a/file.php > $HOME/cron.log 2>&1 This writes the output of the file to cron.log. However, when it runs again, it ...
12
votes
4answers
19k views

How to change the time cron.daily is run in linux

I have a script in cron.daily that runs at a certain time every morning. I need to change the time that it is run. How do I change the time cron.daily runs the scripts?
12
votes
1answer
5k views

How does cron.d notify the system?

If I put a new script into /etc/cron.d/ how does the system know to insert it into the global crontab? Do I need to restart a process to pick it up? Does init run crontab every minute, and it'll ...
12
votes
1answer
10k views

What is the correct way of getting crontab on CentOS 6?

I have a server running CentOS 6.2 minimal, but it doesn't appear to have crontab installed by default? crontab -e -bash: crontab: command not found In searching google, I found references to a "...
11
votes
5answers
2k views

Does 31 necessarily imply the end of the month in a cron job?

For cron job we know we can set time as below. # +------------ Minute (0 - 59) # | +---------- Hour (0 - 23) # | | +-------- Day of the Month (1 - 31) # | | | +------ Month (1 - 12) # | | | | +---- ...