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)

103
votes
4answers
140k 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 ...
13
votes
4answers
911 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 ...
19
votes
8answers
25k 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?
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) ...
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 ...
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?
6
votes
2answers
4k 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 --tmp-...
45
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 ...
21
votes
2answers
15k 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
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 /...
11
votes
3answers
18k 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 ...
7
votes
2answers
2k 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 ...
6
votes
4answers
1k 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
957 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
8answers
894 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.
49
votes
10answers
116k 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 ...
12
votes
7answers
46k views

script to automatically test if a web site is available

I'm a lone web developer with my own Centos VPS hosting a few small web sites for my clients. Today I discovered my httpd service had stopped (for no apparent reason - but that's another thread). I ...
6
votes
5answers
7k views

How to use my aliases in my crontab?

I have some commands in my .profile that I want to invoke from my crontab. For example, if I have, alias notify-me="~/bin/notify.pl -u user1" alias notify-team="~/bin/notify.pl -u user1 user2 ...
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 ...
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-...
13
votes
2answers
610 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 ...
4
votes
1answer
4k 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?
1
vote
2answers
2k 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 ...
6
votes
1answer
5k views

Expired “authentication token” for user with deleted password

The Setup: 1) The user's password was deleted with "passwd -d " command 2) The user has cron jobs running The Problem: Once every 30 days (default password expiration policy) the cron fails with an ...
3
votes
1answer
1k views

logrotate cron job not rotating certain logs

I added two scripts in "logrotate.d" directory for my application logs to be rotated. This is the config for one of them: <myLogFilePath> { compress copytruncate delaycompress dateext ...
2
votes
9answers
7k 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
3answers
6k 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 ...
0
votes
1answer
1k 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 ...
-2
votes
1answer
261 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 ...
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 ...
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?
7
votes
6answers
8k 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 ...
16
votes
2answers
9k 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 ...
21
votes
8answers
50k views

How to disable everything in crontab -l?

I just want to pause everything. Don't execute anything listed on crontab -l.
1
vote
5answers
6k 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 ? ...
10
votes
1answer
13k 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 ...
8
votes
1answer
2k 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
4k 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, ...
15
votes
4answers
15k 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 ...
11
votes
5answers
14k 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 ...
10
votes
6answers
10k 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
3
votes
2answers
5k 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....
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 ...
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 ...
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
4k 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 ...
1
vote
2answers
261 views

Stop crontab from filling syslog Ubuntu 15.04

How can I prevent (certain cronjobs) from filling my syslog in Ubuntu 15.04? I have some jobs that run 4 times a minute and quickly fill up my syslog files. I've tried adding: cron.* ...
6
votes
3answers
5k views

Is it a security risk to run my crontab jobs as root?

I have some cron jobs that I am running - mostly backup related stuff. I am having to backup stuck like /etc/apache2/sites/available etc, which require root access. I have a couple of questions: ...
6
votes
1answer
6k 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 ...
5
votes
1answer
14k views

MAILTO is not working for CRON. How can I fix this?

I have setup cronjob for the root user. However when the cron fail I should receive an email from the cronjob because I have set MAILTO like this in /etc/crontab : MAILTO=my@email.com I have ...