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

learn more… | top users | synonyms (1)

5
votes
2answers
303 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
4answers
2k 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
1answer
7k views

Why does cron silently fail to run sudo stuff in my script?

I have a script run from a non-privaleged users' crontab that invokes some commands using sudo. Except it doesn't. The script runs fine but the sudo'ed commands silently fail. The script runs ...
5
votes
3answers
2k 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
2answers
5k views

Not able to ssh in to remote machine using shell script in Crontab

Below is the script which i am trying to run, which runs without any issue for i in `seq 200 2100` do usr=(`ssh -t -t -o ConnectTimeout=60 machine$1 finger | tail -1 | awk '{print$1}'`) echo ...
5
votes
3answers
1k views

Using notify-send with cron

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without ...
5
votes
3answers
973 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
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
777 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
172 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
2answers
2k 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
197 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
1k 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
462 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
157 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
4k views

cron ignores variables defined in “.bashrc” and “.bash_profile”

I have defined "SHELL" variable in /etc/crontab file: [martin@martin ~]$ grep SHELL /etc/crontab SHELL=/usr/local/bin/bash [martin@martin ~]$ file /usr/local/bin/bash /usr/local/bin/bash: ELF 32-bit ...
4
votes
2answers
220 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
4k 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
476 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 ...
4
votes
2answers
103 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
668 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
361 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
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
1k 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
3k 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
3answers
6k 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?
4
votes
1answer
50 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
1k 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
2answers
10k 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
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
83 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
264 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
32 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
2answers
3k views

crontab's @reboot only works for root?

man 5 crontab is pretty clear on how to use crontab to run a script on boot: These special time specification "nicknames" are supported, which replace the 5 initial time and date fields, and ...
4
votes
1answer
187 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
2answers
3k views

How to run a cronjob in my regular environment?

Both the shell and environment variables that cronjobs are run in is completely different from the ones presented to me in gnome-terminal. How can I run a cronjob under the same circumstances as if I ...
4
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? ...
4
votes
1answer
493 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
113 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
765 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 ...
4
votes
1answer
203 views

How to print the next crontab tasks to be executed?

Is there some way to display a list of the approaching task executions? That is, translate this crontab: # m h dom mon dow command * * * * * imapfilter 4 20 * * Sun fgit gc -- ...
4
votes
3answers
54 views

Cronjob to run script every 3 weeks on Wednesday

Is it possible to schedule a cron job that would run every three weeks on Wednesday (8AM) only? Or, if that is not possible, to run a job every 27 days or less but on Wednesday at 8AM.
4
votes
1answer
179 views

Where is the cron timer

Is there any way to access the cron timers and get the seconds left until the next execution of scripts in the crontab or maybe the seconds since the last?
4
votes
1answer
69 views

When I schedule a command with 'at', can I change where the output is mailed to?

When I schedule a job/command with at to be executed in the future, the standard output and error of the command is "mailed" to the user that did the scheduling. So after my job runs, I get a message ...
4
votes
1answer
653 views

How is cron scheduling actually implemented and makes sure scripts run on time?

I want to ask about cron jobs. OK, we place the scripts in the crontab and the cron daemon executes them. Now if I understand this, each minute, cron checks the crontab of each user and executes the ...
3
votes
3answers
837 views

Is crontab multithread?

I don't know where I can find more information about crontab, so I ask here. Crontab is it multithread? How does it work?
3
votes
4answers
209 views

Does cron jobs per se represent a significant burden on a modern system?

I'd like to run a pretty simple script (is there a dir with name x in dir y if so move it to dir z–and x will only be there about once a day) every 15 seconds or so (one minute divided into 4*15 ...