Cron is used to execute scheduled commands. It acts as a task scheduler on Linux and UNIX systems which will execute commands at specified times set by the user. Cron has a great deal of customization and is often used on server environments where common tasks are run on a regular basis.

learn more… | top users | synonyms (2)

180
votes
3answers
333k views

Where is the cron / crontab log?

I want to verify if my cron job is executing and what time. I believe there is a log for my sudo crontab -e jobs, but where? I searched google and it I found references to look in /var/log ...
165
votes
31answers
230k views

Reasons why crontab does not work

Often, crontab scripts are not executed on schedule or as expected. There are numerous reasons for that: wrong crontab notation permissions problem environment variables This community wiki aims ...
134
votes
5answers
182k views

How do I set up a Cron job?

How do I add Cron jobs in Ubuntu?
38
votes
5answers
37k views

How are administrators supposed to read root's mail?

What is the Ubuntu way for system administrators to receive system notifications, which typically take the form of e-mail sent to the root account? Examples of such notifications are the output of ...
34
votes
3answers
53k views

“(CRON) info (No MTA installed, discarding output)” error in the syslog

I have a fresh install of Ubuntu 12.04.1 LTS an a number of servers. I have not added any cron jobs or edited my crontab on those servers, however, at around the same time for each machine, I get a ...
32
votes
4answers
46k views

Where is the user crontab stored?

Since upgrading my user's crontab has been wiped out. This is not the first time this has happened this year and it's a pain restoring it each time. I'd like to be able to back up the crontab for my ...
24
votes
3answers
45k views

How to run a cron job using the sudo command

Is it possible to run a cron job which needs the sudo command? Like: sudo rm somefile
23
votes
1answer
22k views

How do I make cron email my @gmail account

I have a couple of cron jobs that somethime produce error output and would like to get a notification in my "real" email account, since I don't use my user's mailbox in my Ubuntu laptop, but cron (or ...
17
votes
5answers
15k views

Changing default crontab editor

I am trying to change the default editor from nano to vim. I have run the following commands: sudo update-alternatives --config editor and update-alternatives --config editor Both now output: ...
15
votes
5answers
14k views

Cron.hourly won't run

Ok, So I've made my script, I dropped it in /etc/cron.hourly then I chmod 777 the file but it won't run (automatically). If I manually run it, it works fine. Do I need to do anything else?
15
votes
3answers
24k views

At what time does cron execute daily scripts?

If I place a shell script in /etc/cron.daily/, at what time of the day will it be executed?
15
votes
5answers
30k views

How do you set the timezone for crontab?

I have set up ACPI wakeup so my laptop wakes up at a certain time each morning. The timezone for this is UTC. I want to set up my crontabs also using UTC so they fit with the wakeup alarm. How do ...
14
votes
7answers
59k views

How to run scripts every 5 seconds using cron?

I have a script that needs to be run every five seconds. I know that cron can do tasks by the minute, but is there a way to run something every second?
13
votes
1answer
11k views

Add lines to cron from script

Is there a way to add lines to a user's cron via script? I usually do it using crontab -e, but I would like to automate this task with a shell script.
12
votes
1answer
1k views

What is the story behind the default times set in /etc/crontab?

To my understanding, this is the default configuration of /etc/crontab: # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * ...
11
votes
3answers
24k views

How to execute command every 10 seconds (without cron)?

When I execute cron I get this fault cron: can't open or create /var/run/crond.pid: Permission denied So, how to do it without cron? P.S. I want to check if file in svn has changed and I have a ...
11
votes
2answers
55k views

Script doesn't run via crontab but works fine standalone

I have a script that reminds me to restart my computer if uptime is more than, say 3 days (although its set to 0 days now just to check if the script is running as my computer has been up only over a ...
10
votes
2answers
906 views

How to schedule time-of-day upgrades

I'm responsible for about 30 Ubuntu computers at a private K-8 school. We have only a 3Mbps internet connection serving the entire campus, and I would like to ensure that updates are done in the ...
9
votes
4answers
10k views

Why does apt-get fail when automated with cron?

I'm trying to use cron to automate my system updates. You can see my crontab, commands, and resulting errors below. When I run upgrades.sh as root, the script runs fine. When cron runs it, apt-get -y ...
9
votes
4answers
5k views

Generic solution to prevent a long cron job from running in parallel?

I am looking for a simple and generic solution that would allow you to execute any script or application in crontab and prevent it from running twice. The solution should be independent on the ...
9
votes
3answers
20k views

Cron Job Not Running?

I have a crontab file that looks like this: * * * * * /home/abliskovs/update/update.sh However when I check the syslog for evidence that the job has run, there is nothing that might indicate that it ...
9
votes
2answers
9k views

All commands in my crontab fail with “Permission denied”

crontab -e and crontab -l work just fine: $ crontab -l | grep -v '^#' * * * * * /usr/bin/env * * * * * echo 'Hello from crontab' However, I see two messages like this every minute in ...
8
votes
3answers
29k views

How can I tell if my hourly cron job has run?

I have created a file called ntpdate in /etc/cron.hourly #!/bin/sh /usr/sbin/ntpdate-debian date > /tmp/william_tmp date > /william_tmp date > ~/william_tmp echo test I also did Chmod 755 ...
8
votes
4answers
4k views

“Backup Intervals” in rsnapshot.conf?

A simple question about rsnapshot. In order to perform daily backups I'm going to add lines to cron in my Ubuntu. Then, why do I have also these lines in the rsnapshot.conf ? ...
8
votes
4answers
6k views

What kind of harm there is from removing (purging) package apt-xapian-index?

I know you can't use Quick filter in Synaptic after purging apt-xapian-index, but is there something more severe? I know there are some performance issues, when you have it: ...
7
votes
3answers
13k views

How can I setup a Mail Transfer Agent?

I intend to use mutt to send automated emails via cron or at with attachments to my gmail address when particular events happen on my Ubuntu server. Currently, mutt cannot send email to external ...
7
votes
3answers
6k views

Can symlinks be used in /etc/cron.d/?

I'm trying to implement a configuration mechanism that allows in a certain project to deploy through svn a cron configuration. I immediately thougt that what I should do is cerate symlinks from ...
7
votes
2answers
23k views

How can I see/stop current running crontab tasks?

How can I see crontab tasks which are in progress? How can I stop crontab tasks which are in progress, manually? Is [this] question about see the current running cron processes? Yes To ...
7
votes
2answers
2k views

what can be causing /etc/cron.daily/apt to hang?

Lately I've been getting a mail from the server every day, Subject Cron <root@host> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) Body ...
6
votes
4answers
17k views

How to restart every 30 minutes automatically?

I would like to schedule a restart of my Ubuntu every 30 minutes. Is there any command or a graphical way to do it?
6
votes
3answers
10k views

Daily cron job not running

A quick overview: I have a script that will daily backup my source code repository from SVN into a tarball for that day. I have tested the script and it works very well as long as I run it as sudo, ...
6
votes
4answers
29k views

Verify if crontab works

I want to verify if a certain crontab works properly. I have added a job like this: */2 * * * * /path_to_my_php_script/info.php >/dev/null 2>&1 I know that i redirect to the null ...
6
votes
2answers
2k views

Keep getting mails about xdebug

I'm running Oneiric as a LAMP development server, and have xdebug installed. It works fine, but since I set up my email so that root mails are forwarded to my gmail, I keep getting the following: ...
6
votes
2answers
3k views

How to run a script only once per day with cron without specifying execution time

I wan to run a backup script once per day but i dont want to specify a certain time, just once per day. I've read that the @daily cron attribute runs every day at 00:00 but i don't know if the ...
6
votes
5answers
9k views

What's wrong with my cron.hourly configuration?

Every hour I get an email with error like this, Subject: Cron <root@supa> root cd / && run-parts --report /etc/cron.hourly /bin/sh: root: not found Contents of /etc/crontab is as ...
6
votes
2answers
7k views

What is my crontab -e local file path? I want to set it via BASH script

In my Ubuntu, my username is "meuser". When i do crontab -e, i can setup my rules. But instead of doing it with crontab -e, how can i do it directly to a file? Which file i cant modify?
6
votes
2answers
2k views

Why do I see a CRON session opening and closing every hour in /var/log/auth.log?

I am quite fresh with Linux as a whole, so this may be a silly question - but I would still like to know the answer This morning when I look at my /var/log/auth.log (which I've been told to make a ...
5
votes
5answers
7k views

cron.daily jobs not running

I created 3 daily cron jobs to run. Below are the three that are placed in etc/cron.daily rkhunter.sh #!/bin/sh ( rkhunter --versioncheck rkhunter --update rkhunter --cronjob --report-warnings-only ...
5
votes
3answers
2k views

Need help with bash checking if computer uptime is greater than 5 minutes

I have an bash script that runs on a every minute cron. It checks to see if a necessary program is running and starts it if it is not. Occasionally it will run before the user has actually autologged ...
5
votes
4answers
8k views

Setup CRON weekly backup

I want to make a backup of my /var/lib/mysql and /var/www folders and save them as tar.gz files to my mounted network file server (uslons001). Here is my bash file located in: ...
5
votes
1answer
4k views

How to start / stop Dropbox at a specific time

I have setup a service on my Ubuntu 10.04.4 LTS server, which works when started and stopped manually using sudo service <service> start etc. However I would like to have the service (dropbox ...
5
votes
1answer
705 views

What is the easiest way to set up a cron job?

Every time I set up a cron job there is something wrong with it and I spend a lot of time trouble shooting it. I use Ubuntu and I would like to know what tools exist to make my life easier when ...
5
votes
2answers
1k views

NMCLI works in script when I run itdirectly , but not when run in CRON

This is under Ubuntu 11.10 I have a script that starts a PPTP VPN connection fetches a couple of files, then closes the connection. When I run this script from a terminal prompt it works perfectly; ...
5
votes
1answer
2k views

Schedule sending mail of a log file content

I have postfix mail agent installed and I've configured gmail relay and I could send mails from the terminal as below: root@statino1:~# mail -s "subject_here" my_gmail_id@gmail.com CC: <hit enter ...
5
votes
1answer
311 views

Is it possible to use the 'screen' command to work with files on an encrypted home directory?

So I have an encrypted home directory, set up during install on a server running Ubuntu 12.04 LTS. I attempted to use screen in order to run a script that accesses the data in my home directory after ...
5
votes
1answer
2k views

“CRON: Module is unknown” after upgrading to 10.04

I just upgraded our server to Ubuntu 10.04 and cron just stopped working. I tried to restart the server, restart cron but nothing worked for me. It just reports in /var/log/syslog: May 12 16:32:01 ...
5
votes
2answers
2k views

How can I create a cron command that will execute a command inside a detached screen?

I have created a screen, but can I now somehow execute a command that will run commands in the detached screen? I do not even know if this is possible, but if it is, it will probably be something ...
0
votes
1answer
12 views

cron runs at wrong time

I have a /etc/crontab file. It's pretty much the default one except for the daily tasks: '# m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly ...
0
votes
0answers
4 views

incron tab won't fire

I'm trying to get incrontab running, but it won't work. This is the error I get: access denied on ~/propt/apo/feeds - events will be discarded silently and this is the line in incrontab I want to ...
0
votes
1answer
40 views

run a script and return system to suspended or running mode

Somehow I cannot find how to do this common task. I want to run a (backup) script daily at certain time regardless whether the system is running or suspended and return to the previous state ...