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)

200
votes
5answers
278k views

How do I set up a Cron job?

I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this. How do I add Cron jobs in Ubuntu?
203
votes
34answers
314k 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 ...
45
votes
5answers
45k 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 ...
243
votes
4answers
473k 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 ...
33
votes
3answers
64k 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
10
votes
3answers
15k 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 ...
5
votes
3answers
2k views

Programmatically sync dropbox without daemon running

I would like to 'manually' force dropbox to sync at certain times (eg at regular, daily intervals using cron, as part of a larger backup script). My goal is to substitute the dropbox daemon with ...
3
votes
1answer
6k views

Stop cron from mailing the user

I am facing an issue with Ubuntu server. I am running a PHP script using a cron job which executes every 5 minutes. This folder spool/mqueue is showing 112GB space. The scripts job is to fetch data ...
7
votes
2answers
1k views

How to start a GUI application from cron?

I need to run a Java applet from a Firefox. The problem is, I need to run this Firefox from a cron. If I run from the command line and its work fine, but when put the command in the cron it failed: ...
9
votes
4answers
8k 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: ...
2
votes
2answers
9k views

Getting output from a cron job on the terminal

I have a program that prints some output that I would like to pop up on my terminal once every hour during the workday. $ crontab -l 0 07-17 * * * /home/dat/scripts/cron.out syslog reports the ...
0
votes
1answer
104 views

How to create a perl script which checks the system stats(CPU,RAM,HDD) and sends an alert mail? [closed]

The script is for adding to the cron tab. The flow of the shell script should be like this. 1. Checks the CPU state. 2. Checks the RAM usage. 3. Checks the HDD usage. 4.Sends an alert mail to ...
60
votes
4answers
93k 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 ...
21
votes
5answers
19k 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?
17
votes
1answer
16k 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
3answers
36k 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 ...
18
votes
6answers
45k 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 ...
6
votes
5answers
12k 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
2answers
3k views

Automating duplicity backups using cron

How do I automate duplicity backups using cron using gpg encryption and the ssh backend?
4
votes
1answer
3k views

shut down linux server and turn on automatically at specific time

I'm having an assignment where the lecturer is asking me to create a bash script to shut down a server at 11pm and turn it on at 6am. I'm able to do it by using sudo shutdown -h 23:00 and it works. ...
2
votes
5answers
40k views

How to Setup a root cron Job Properly

I tried to setup a root cron job to run a Bash script as root, to run at minute 7,37, every hour, every day of month, every month. This script is located in /usr/bin and named tunlrupdate.sh is used ...
2
votes
1answer
844 views

Schedule to turn off monitor via crontab?

I want to turn off monitor on a specific period of time automatically (for example between 07:00 and 11:00). Is there any command to be set in crontab file? Is there any better way? In summary: ...
1
vote
1answer
177 views

Cron fails at night

I have set up a cron job, but for some reason it fails to run during the night. The same job runs fine when i'm running it during the day (i.e. setting up the same job to run in a few minutes and ...
4
votes
1answer
1k views

Is there a programmable way to tell if the screen is locked?

I have lots of stuff in my crontab, including some that talks to my screen. If I'm not there for it to be notifying, I don't really want it to run. Is there a way I can check to see if the computer ...
0
votes
3answers
359 views

Run rkhunter regularely on a desktop system

I want to get a warning on my desktop when rkhunter finds something odd on my system. I whitelisted some files and dirs that seem ok in /etc/rkhunter.conf so I get no warnings anymore. Now I want to ...
0
votes
2answers
677 views

Set server timezone but not working with crontab and phpmyadmin

TimeZone is not working properly I am using linode server running ubuntu 12.04LTS. My Question is when i configured timezone by using dpkg reconfigure tz as IST ASIA/Calcutta. It shows correct ...
24
votes
6answers
22k 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: ...
14
votes
2answers
78k 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 ...
4
votes
3answers
4k views

unattended-upgrades not running, /etc/cron.daily/apt missing

I have automatic-upgrades installed and configured, but it never seems to run, because there are always security updates waiting to be installed when I check. ...
8
votes
2answers
21k views

How to stop email report from Cron <root@machine> (hourly)

I'm running an Ubuntu 12.04, I've configured "ssmtp" with my gmail account and now I'm getting every hour an email with a report, this is an example: From: root <my@gmail.com> Date: 2012/8/13 ...
10
votes
4answers
11k 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 ...
6
votes
3answers
23k views

How do I configure exim4 to send mail through a password protected ssl smtp mail server?

I'd like my cronjobs to be able to send mail from my home computer. My servers configure exim4 like this: dc_eximconfig_configtype='internet' dc_other_hostnames='' dc_local_interfaces='127.0.0.1' ...
6
votes
2answers
8k 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?
5
votes
1answer
3k views

Hourly GIT Push

Is it possible for me to automate a Git push every hour via a batch script. I would typically type in this: git add * git commit -m "latest update" git push ...
3
votes
2answers
7k views

How can I set up a php script to run via cron?

How can I set up a php script to run via cron I've created a file in the cron.d folder with the username as the file name: /etc/cron.d/username Inside of username file I placed the following cron ...
3
votes
3answers
2k views

Cron not able to succesfully change background

I'm running 12.04 with a custom XML background (modification on Day of Ubuntu) that changes based on time of day. I've noticed that there's a significant delay between when the changes are scheduled ...
3
votes
4answers
5k views

execute script after desktop loaded?

I want to execute bash script on startup that opens several terminals in different workspaces. Script works just fine if I call it from terminal, but it doesn't work if executed from crontab using ...
13
votes
1answer
2k 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
40k 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 ...
9
votes
3answers
3k 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 ...
7
votes
3answers
6k views

Why is this rsync + ssh cron job giving me 'Permission denied (publickey)' errors?

I make frequent backups to a local drive which I want to sync daily to a remote server. The target server is configured for SSH key (no password) access only. Since my primary SSH key for that server ...
7
votes
3answers
11k 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
1answer
787 views

Schedule to record video stream in VLC

I work at a school and have setup a workstation to broadcast/stream the morning announcements for the teachers and kiddos. Teachers in the classroom access this stream via Windows Media Player or ...
4
votes
6answers
3k views

How to run cron job when network is up?

I have some anacron jobs which run daily. The scripts update local bzr and git repositories. Naturally these scripts need working network connections. I'm on a laptop and often wired and wireless ...
3
votes
3answers
143 views

Cron execution question

Suppose I set up a cron job with anacron, or with crontab -e. Now, what if my machine is switched off at the moment cron should have executed the scheduled job? Would the job be executed as soon my ...
2
votes
2answers
1k views

Setting cron to run a shell script: random wallpaper from a webpage

I have written a shell script which downloads random wallpaper from a web-page and sets it as a background every 5 hours. Here is the script: #!/bin/bash countervar=1; finish=0; cd ...
2
votes
3answers
8k views

Deleting a file owned by root

Recently, a friend played a prank on my pc and now I have a file sitting on my desktop called 'hardcore_porn_xxx'. The problem is it does not go away by a simple delete. I'm new to linux so any help ...
1
vote
1answer
9k views

Crontab Shut down command didn't work

I wanted Crontab shut down the system daily but it didn't do so, did I misspelled something? This is my Crontab file: /etc/crontab: system-wide crontab Unlike any other crontab you don't have to ...
1
vote
3answers
21k views

Use /etc/aliases for outgoing mail relayed by postfix with local domain

I'm using Ubuntu 12.04 with postfix configured as satellite system that relays outgoing mail to Gmail. For sake of example, my registered domain is example.com I want root cronjobs' error output to be ...
0
votes
2answers
2k views

How to append text to file every morning?

I would like to append current date to text file every morning at 7am. if the computer is turned off I would like it to be executed after its turned on.