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)

47
votes
3answers
29k 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 ...
14
votes
7answers
14k 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?
12
votes
4answers
690 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 ...
6
votes
2answers
2k views

My cron tasks report command not found [duplicate]

This is the contents of my crontab file: 0 0,6,12,18 * * * cd /var/www/app/current && backup perform --trigger db_backup --config_file config/backup.rb --data-path db --log-path log ...
2
votes
8answers
741 views

How to run a cron job?

I have a sample perl script which i need to run using cron daily ,could any one let me know the exact syntax to use cron job. Thanks in advance.
10
votes
2answers
6k 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
6answers
8k 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?
5
votes
2answers
791 views

Timezone for cron jobs

We have a VDS running CentOS 5.5 that was created and configured with the EDT timezone. I have replaced etc/localtime with a link pointing to the Australia/Melbourne (UTC+10) timezone file. Running ...
21
votes
6answers
2k 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 ...
12
votes
7answers
29k 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 ...
8
votes
7answers
3k views

How to perform cron jobs failover?

Using two Debian servers, I need to setup a strong failover environment for cron jobs that can be only called on one server at a time. Moving a file in /etc/cron.d should do the trick, but is there ...
12
votes
5answers
11k 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 ...
5
votes
5answers
3k views

What's the best way of setting up a cron job to check that a long-running process is still going and if not, start it?

As per the title: What's the best way of setting up a cron job to check that a long-running process is still going and if not, start it? If I start a long-running process in cron, is it going to ...
13
votes
2answers
541 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 ...
1
vote
2answers
953 views

executing a sh script from the cron

I have a test.sh script #!/bin/sh php /home/v/file.php sh /root/x/some.sh when I execute the file as root from command line it works. sh /home/v/test.sh when I set it to crontab -e (is the root ...
0
votes
3answers
3k views

Command does not execute in crontab while command itself works just fine

I have this script from Colin Johnson on Github - https://github.com/colinbjohnson/aws-missing-tools/tree/master/ec2-automate-backup It seems great. I have modified it to send email to myself every ...
8
votes
2answers
2k 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 ...
5
votes
4answers
495 views

Crontab running before nfs mounted

Running Cronjob @reboot returns that file on nfs share does not exist. Example @reboot python /abs/path/to/script.py mail from crontab on startup reads "more or less" /usr/bin/python can't open ...
3
votes
5answers
776 views

Difference of running scripts manually or with a cronjob

I have a PHP script that I want to run every 10 minutes, going through database records and creating/editing movies through MEncoder. I've set up cron job to accomplish this, but it doesn't work very ...
2
votes
9answers
5k views

CronTab: Not running my PHP scripts?

final edit: i have moved this to http://serverfault.com/questions/168662/406-error-with-get-cron-job EDIT 4: i am getting a 406 error page with this cron! here is the crontab (copied from cPanel): ...
0
votes
1answer
692 views

No log handling enabled - turning on stderr logging Cannot find

I'm trying to setup a Cron Job that runs a .php file that will automate client email correspondance. I've created the .php file and the Cron Job through cPanel. Everything works fine in that I'm ...
0
votes
3answers
3k views

crontab to run bash script (ssh command in it) not working

CentOS 5.4 (in my script file - script.sh) #!/bin/bash ssh 192.168.0.1 'iptables -L' > /tmp; (in /etc/crontab) 30 21 30 9 * root /bin/bash /script.sh If I run the script in terminal, things ...
-2
votes
1answer
221 views

shell script doesn't run correctly in cron [closed]

I want to call a shell script I wrote from a cron. The shell script uses the program Linkchecker. If I run the shell script from the terminal it works just fine. However, when cron runs I get the ...
26
votes
7answers
11k 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 ...
7
votes
6answers
6k views

crontab environment

I have written various scripts to launch Java server applications, which are typically run for 24 hours before being shut down (by invoking the same script with a different parameter). The script ...
1
vote
5answers
5k views

How can I keep my server from being clobbered by zombies from this Ubuntu cron job to remove PHP sessions?

I recently noticed when I logged in that I had several thousand processes marked "zombie". Upon further investigation, I found the following from ps fax: 701 ? Ss 0:28 cron 3363 ? ...
8
votes
2answers
4k 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 ...
10
votes
5answers
9k views

Using mysqldump in cron job without root password

If I login with the root password on my box I can simply type mysqldump --all-databases and I will get th expected "Dump". I setup a job in cron.daily to run and dump this to a backup drive. The ...
8
votes
3answers
9k views

How can I test a new cron script?

I'm running on a couple of different Linux distros (Fedora 11, CentOS 5 and SuSE 10.2) and often run into a problem where a new script that I want to run as a cron job works fine when called direct ...
6
votes
1answer
1k views

FreeBSD: periodic(8) is too noisy. How can I control the noise level?

FreeBSD & MacOSX ship with the the periodic(8) utility, which is a neatly organized set of utilities to periodically run system functions like ZFS filesystem checks, security checks, checking for ...
1
vote
2answers
3k views

How does one determine active SSH and SAMBA connection counts?

I have a server that I use infrequently, so I'd like to cron a job to shutdown daily if no users are logged in via SSH and SAMBA shares. How can I determine how many active SSH connections there are, ...
7
votes
6answers
14k views

How to disable everything in crontab -l?

I just want to pause everything. Don't execute anything listed on crontab -l.
5
votes
1answer
4k views

What's the difference between /etc/cron.d and /var/spool/cron?

The crontabs on RHEL seem to be duplicated in two places, /etc/cron.d, and /var/spool/cron. I've checked, and neither of these are simlinks to the other, and neither are any of the crons contained in ...
5
votes
3answers
3k views

/etc/cron.daily/apt and /etc/cron.daily/aptitude on ubuntu hardy

I am a sys admin newb, otherwise I would figure this out on my own. I have a slicehost slice and I noticed that there are a couple scripts that get run (the ones I mentioned in my question title) ...
2
votes
1answer
3k views

Redmine: fetch changesets from cron job

In Redmine 0.8.2, I want changeset information fetched automatically, instead of only when someone views the Repository tab of the corresponding project. (I need this so that commit messages ...
13
votes
3answers
5k 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 ...
6
votes
6answers
5k views

deleted cron tab file and need to recover it

I ran crontab -r instead of crontab -e and deleted my crontab file. I didn't have a backup and new to recover the deleted file. Is this possible? Thanks, Peter
5
votes
1answer
4k views

Users cannot use crontab after password security upgrade

I have a box being upgraded from CentOS 5 to CentOS 6. On the original server, all users have MD5 passwords. The upgraded server is now using SHA-512 passwords. Users who have changed their password ...
4
votes
3answers
3k views

Where is this cron job running from?

Some time ago, I set up a cron job to run a script every minute. Since then, I've upgraded the system from ubuntu intrepid to ubuntu karmic. Now the job is failing. I get email about it once a minute. ...
4
votes
2answers
3k views

pptp (pon) fails when called via cron (debian) [solved]

I have a pptp VPN link dialing from my (debian) linux server here, to an ISA2003 server at a remote site. The internet connection at (both) ends is somewhat dodgy, so I have written a little script ...
3
votes
2answers
3k views

Can't get cron.hourly to work

I installed cron with sudo apt-get install cron, started it as root and confirmed that it is running with ps -ef I then created a simple script with the following contents: touch ...
3
votes
2answers
360 views

How do I write integration tests for cron jobs?

I have a series of cron jobs and I would like to test them in a more timely and automated way than the following: Test individual jobs in isolation by running them manually. Install job and update ...
3
votes
1answer
3k views

How do I set a time zone for a crontab?

I would like to use UTC for the scheduling times in a crontab for a single user, regardless of the current time zone of the server. How do I do this on Debian Etch?
3
votes
3answers
9k views

Cron job to open a webpage?

I have a web page at http://mydomain.com/process/2909 I want a cron job to automatically hit this page every night at 2 am. I was going to get cron to run a PHP script that opens the website with ...
2
votes
6answers
6k views

How to stop Cron from sending messages about errors

I have this strange mails comming from cron: Return-Path: <root@domain.com> Delivered-To: root@domain.com Received: by domain.com (Postfix, from userid 0) id 6F944264D0; Mon, 10 Jan 2011 ...
2
votes
3answers
150 views

Cron job unified logging

I have a series of cron jobs on a server machine. I know I can redirect their stdout/stderr output to a file. If I redirect several cronjob outputs to the same file, will that work even if some of the ...
1
vote
2answers
1k views

Incrond running but not executing commands CentOS 6.4

I have copied this question over here from StackOverflow... I have installed incron from the EPEL repository (0.5.9) (before you ask; YES, I also tried downloading the source and compiling locally ...
0
votes
3answers
4k views

crontab execution doesn't have the same environment variables as executing user

I ran my crontab job 0 2 */1 * * /aScript >aLog.log 2>&1 as a 'root' user, and however I found the env is different from env of the 'root' user, and therefore experiencing a different ...
11
votes
1answer
3k 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 ...
4
votes
4answers
1k views

stop linux from emailing me cron errors?

Today i setup ssmtp to email me from sendmail. However what i didnt expect is that applications like cron would email me. One of my cron scripts before backing up the db tries to create ...