Cron is a job scheduler that allows users to run commands periodically.

learn more… | top users | synonyms (1)

6
votes
3answers
786 views

sort at jobs chronologically

Possibly a simple solution I misplaced. How can I get the output of atq sorted chronologically, so I can easily see who's due to run next? The man page for sort doesn't have anything built-in to ...
6
votes
1answer
3k views

What's the meaning of the slash in crontab?

I have seen a crontab record in system. 0-55/5 * * * * root <command> I read the crontab -e example files and I know the first position stands for minute. But I cannot figure out the ...
6
votes
1answer
2k views

Recover cron jobs accidently removed with crontab -r

I entered crontab -r instead of crontab -e and all my cron jobs have been removed. What is the best way (or is there one) to recover those jobs?
6
votes
2answers
3k views

Logging ALL stderr output of crontab to file

For example, I can log stderr of one script in this way: * * * * * run_script.sh > /var/log.txt 2>&1 But I want to log stderr of all scripts in my crontab. I can append > /var/log.txt ...
5
votes
6answers
1k views

What does '>/dev/null 2>&1' mean in this article of crontab basics? [duplicate]

I am reading an article about crontab There is something about disabling automatically sending emails. Disable Email By default cron jobs sends an email to the user account executing the ...
5
votes
2answers
1k views

Open emacs in a terminal when editing crontab

I have setup emacs as my default editor in /etc/profile. When I want to use emacs in a terminal. I open it with the -nw option. How can I have the same behavior when doing a crontab -e preventing it ...
5
votes
5answers
3k views

Check if script is started by cron, rather than invoked manually

Is there any variable that cron set when it's running a program ? If the script is running by cron, I'll skip some parts; otherwise invoke those parts. How can I know if the bash script is started by ...
5
votes
2answers
329 views

cron every X exact meaning

In cron you can specify */n where n means every n times period, for instance in the first column is minute. */5 means every 5 minutes, but which minutes? 0, 5, 10, ...? What happens if the number ...
5
votes
3answers
834 views

Cron to not run on specific day but all other days

I have a cron setup to execute a bash script daily at 10pm. I have another cron setup to run monthly on the 1st of the month. Both crons launch a bash script, and the only different in the bash script ...
5
votes
1answer
13k views

Crontab job start +1 min after @reboot

Need a script executed at each reboot in +1 minute. I placed a record @reboot but it is too early for my script. How to execute it sometime after reboot?
5
votes
3answers
3k views

How can I ensure my cronjob will run at specified time?

I'd like to know how I can check to see if my cronjob will run at the specified time I set it at. Is there anyway I can test this without having to wait for that time? Here are my crontab -l results: ...
5
votes
3answers
7k views

How to add unique id to file name in cron job?

My cronjob looks like this: 5 3 * * * mysqldump -u root test > /srv/backup/mysql_daily.dump How can I make filename unique for every time when cronjob writes mysql_daily.dump?
5
votes
3answers
1k views

How to get which version of cron daemon is running

Background: I am working on CentOS Details # cat /proc/version Linux version 2.6.18-308.4.1.el5PAE (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) #1 SMP Tue Apr 17 ...
5
votes
3answers
817 views

Crontab job not emailing on failure

I have a cron job on Debian: 1 * * * * /home/paradroid/bin/myscript.sh >/dev/null There is an installed and configured MTA, and I have received emails when the script has a syntax error, so I ...
5
votes
3answers
2k views

Frustrating issue where neither cron nor su -c runs my job (permissions?)

Updated (and snipped) with more details below. I've set up a cron script and I'm trying to debug why it's not running. [Snipped context testing, which is all ok; see revision 2 for details] The ...
5
votes
3answers
229 views

Is any extended logging available for cron jobs?

I have 3 scripts under /etc/cron.daily. My cron logs are written in /var/log/cron. The below is an entry for the above cron that has run. (root) CMD (run-parts /etc/cron.hourly) Here the stdout or ...
5
votes
5answers
2k views

How can I use cron to display messages on the screen via notify-send

I am toying around with notify-send and cron (on an Arch machine) and I can't figure out a way to combine them: I tried the solution given here and here, but neither worked. How can I use them? ...
5
votes
2answers
3k views

Scp doesn't work in cron

Yeah, I know it's classic. I've googled it all around, but still it doesn't work. I have the following script: #First go to SVN repo folder cd $svnrepos # Just make sure we have write access to ...
5
votes
2answers
229 views

How to schedule a job that depends on network availability?

I have cloned a git repository of some project. I want to automate git pull and compile the project once in a week. I am using a laptop which wont be on 24x7. Now, I cannot use cron as I should keep ...
5
votes
3answers
2k views

What could cause a cron to run twice at the same moment?

I have a cron that is setup to run every Monday at 1 AM 0 1 * * 1 /script/dir/script >> /script/dir/file.log After two years of running as expected, it ran twice on June 18, with the second ...
5
votes
1answer
540 views

Run script when specific users logout

I need to run my application in screen when specific users are logged out and kill the screen when someone from my user list logged in. So I am thinking about bash script, which will be called ...
5
votes
1answer
1k views

Running cron script with lynx fails to work

I'm trying to automate a login process that can only be done through a browser. I am using the lynx browser to script the actions required to do this. Lynx does this by dumping a user's keystrokes ...
5
votes
0answers
462 views

CRON Permission Denied [closed]

I have a Debian 7. 3 Server with WebMin installed. I configured a cron job to run every minute as root user, so I run the command crontab -l when I'm logged in as root it shows: * * * * * ...
4
votes
2answers
440 views

Schedule job at irregular intervals

It's simple enough to use cron to schedule a job to occur periodically. I'd like to have something occur less regularly -- say, run the job, then wait 2 to 12 hours before trying again. (Any ...
4
votes
2answers
5k views

Cronjob to run every 30 minutes

I want to set a cronjob entry that runs a script every 30 minutes from 9:00 to 18:00 but I do not want it to run at 18:30. The script should run for the first time at 9:00 and for the last time at ...
4
votes
2answers
157 views

Execution order with multiple commands

I'm relatively new to Linux and I'm working on a CronTab for scheduled backups. I figured out how to do multiple sequential jobs with ; and &&, but I'm unsure how the dependency affects the ...
4
votes
3answers
796 views

What's the purpose of having different crontabs per user?

Is it just for controlling the permissions of the script being called or does it also effect when or if the script runs? I assume if I setup a cron for a non-root user it should always run, even if I ...
4
votes
2answers
479 views

why doesn't 0 0 * * 1 root hostname >> /tmp/hostname.txt work as a crontab?

0 0 * * 1 root hostname >> /tmp/hostname.txt The above cron entry should run midnight on monday and create a file in /tmp called hostname.txt with the output of the hostname command. But it is ...
4
votes
3answers
6k views

Can I use logrotate to compress daily (date named) logs?

I have logs in the following format: YYYYMMDD I want to compress old logs (older then current day) and maybe move them to a different directory afterwards. Can I do this in logrotate, or do I have ...
4
votes
2answers
288 views

Does cron know that the instance to be scheduled is already running?

I was wondering if we add a job in the crontab e.g. to run every 5 mins and the job does not actually manage to finish in 5 mins, does the cron daemon know that the previous instance is already ...
4
votes
2answers
5k views

How to find a cron job if you know the specific time it runs?

I've been using kSar to look at my servers resource use. There is a definite spike in process creation at 4:04AM daily. Cron seems to define the interval they should be run, but not the specific time ...
4
votes
3answers
18k views

How to start a cron job without reboot?

I use a cron job to call offlineimap every 2 minutes: */2 * * * * /usr/bin/offlineimap > ~/Maildir/offlineimap.log 2>&1 I needed to kill the cron job to fix a problem. How can I then ...
4
votes
3answers
1k views

In linux, would it be possible to run a script every day 3 minutes later than the previous day?

My first solution to this was to execute date +%Y%m%d%H%M and put that format of numbers into a file, and run the script every minute from cron. Then if the date from the file matches the date ...
4
votes
2answers
2k views

/etc/crontab permissions

The /etc/crontab file has the permissions: -rw-r--r-- I understand that this file is for system cron jobs and other users should not have permission to modify it. The current permissions allows all ...
4
votes
2answers
4k views

How can I know when a cron job was killed or it crashed?

Usually when a cron job crash, it will leave some error messages in the log. We run shell script and some java program with cron job. Recently we found some weird thing out from the log. Obviously ...
4
votes
1answer
61 views

Is it possible to put arithmetic expressions in a crontab?

I know I can do simple arithmetic in shell scripts, like so: #!/bin/bash ((sum = 1 + 2)) echo sum This will output 3 on execution. My question now is, can this kind of expressions be used in ...
4
votes
3answers
2k views

Cron allowed special character “L” for “Last day of the month” on Debian

I'd like to know if L is one of the allowed special characters on Debian's cron implementation? I'm trying to set up a cron to run on the last day of every month. From the cron entry on wikipedia: ...
4
votes
1answer
138 views

In crontab is it possible to specify a user from a variable?

I am trying to have the following cron executed with a certain user. U=`/usr/bin/w | grep -w :0 | awk '{ print $1 }'` */1 * * * * $U /opt/script.sh It seems the deamon doesn't know how to interpret ...
4
votes
2answers
9k views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
4
votes
2answers
921 views

System Crontab or Root Crontab

System crontab: /etc/crontab Root crontab: sudo crontab -u root -e Which way is preferred? As they all run tasks within administration privilege.
4
votes
1answer
1k views

start-stop-daemon makes cron pidfile with wrong pid

I have an init.d script to start crond which specifies the following for start(): start-stop-daemon -S --quiet --make-pidfile --pidfile /var/run/crond.pid --background --exec /usr/sbin/crond ...
4
votes
2answers
281 views

crontab, instance, memory issues+spamming

I have a cronjob that runs php5 wp-cron.php every minute to update my website. However something happened and i had 30+ instance of it (31 is marked on this one dump of ps aux). It ate up my ram, ...
4
votes
2answers
1k views

cifs write errors in cron job

EDIT: THE SOLUTION With Tim's help I determined that larger writes of data were failing versus smaller ones. Why they didn't fail when I ran the script interactively, I don't know...But here was the ...
4
votes
2answers
73 views

Create new temporary directory

What's an effective way of creating a new /tmp directory, that behaves just like /tmp (purged on reboot, etc.), but in a different location? In my case, I want to create a ~/dev/tmp directory where I ...
4
votes
1answer
688 views

Automatically detect when a file has reached a size limit

I would like to send an email when a file reach a certain size limit. The only way I thought of doing this is by doing a cronjob which will check the file size and send the email if the file is ...
4
votes
1answer
206 views

Emptying a directory owned by another user weekly

I have a temp directory set up where users can place whatever files they need to send to other users via HTTP. The owner of this directory is an SFTP user, and cannot run cron jobs. I have one shell ...
4
votes
1answer
790 views

How to use cron + python to regularly adjust screen brightness?

I want to use cron and this script (http://askubuntu.com/questions/23593/use-webcam-to-sense-lighting-condition-and-adjust-screen-brightness): import opencv import opencv.highgui import time import ...
4
votes
1answer
514 views

How can i dump /tmp/files in CentOS to Dropbox using crontab?

How can i dump files from my CentOS box to Dropbox account? As regular nightly backup task.
4
votes
1answer
232 views

BASH_ENV and cron jobs

I have several questions related to non-interactive, non-login shells and cron jobs. Q1. I have read that non-interactive, non-login shells only "load" $BASH_ENV. What does this exactly mean? Does ...
4
votes
2answers
1k views

Have cron email output to MAILTO based on exit status

I have a cron job running a php command like this: php /path/to/script.php > dev/null This should send only STDERR output to the MAILTO address. From what I gather the php script is not ...