Questions tagged [cron]
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.
134
questions
395
votes
7
answers
970k
views
Why is my crontab not working, and how can I troubleshoot it?
This is a Canonical Question about using cron & crontab.
You have been directed here because the community is fairly sure that the answer to your question can be found below. If your question is ...
128
votes
11
answers
91k
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 ...
47
votes
13
answers
72k
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 [email protected].
How could I change it to something like [email protected]?
15
votes
4
answers
1k
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 ...
106
votes
2
answers
48k
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`" s.o+`hostname`@gmail.com
I need ...
26
votes
2
answers
7k
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) ...
163
votes
12
answers
332k
views
Best practices for setting a cron job for Let's Encrypt (Certbot) renewal?
Is this correct way to set cron for renewal of Let's Encrypt cert in Apache2 ?
I use Ubuntu 16.04.
@monthly letsencrypt renew && service apache2 reload
12
votes
4
answers
7k
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 ...
70
votes
3
answers
57k
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 ...
65
votes
10
answers
74k
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?
8
votes
2
answers
6k
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-...
56
votes
6
answers
74k
views
Cron: Only get errors in emails?
I finally set up a realistic backup schedule on my data through a shell script, which are handled by cron on tight intervals. Unfortunately, I keep getting empty emails each time the CRON has been ...
15
votes
3
answers
31k
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 ...
8
votes
4
answers
4k
views
How to customise email headers from Vixie-cron (debian) and msmtp?
I have had some trouble with getting cron to send emails. My ISP requires that the "From:" field match the email address the email is being sent from, otherwise the email is rejected. As cron ...
7
votes
2
answers
5k
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 ...
3
votes
5
answers
6k
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
8
answers
2k
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.
166
votes
14
answers
561k
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 ...
83
votes
3
answers
152k
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-...
61
votes
6
answers
36k
views
How to Modify a Cronjob Email Subject
I am running a half dozen different cron jobs from my hosting at Hostmonster.com. When a cronjob has been executed I receive an email with the output of the script.
The email comes in the format of:
...
43
votes
6
answers
50k
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 /...
25
votes
7
answers
24k
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 ...
19
votes
5
answers
16k
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 ...
13
votes
2
answers
959
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
...
12
votes
2
answers
55k
views
Cronjob run every two weeks, on Saturday, starting on this saturday
Today is Friday, October 3, 2014 3:58 AM
I want to schedule a cronjob like that to run it at the following dates:
Saturday, October 4, 2014 8:00 AM
Saturday, October 18, 2014 8:00 AM
Saturday, ...
8
votes
3
answers
10k
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 ...
5
votes
1
answer
12k
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
...
5
votes
5
answers
5k
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 ...
5
votes
2
answers
5k
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?
4
votes
2
answers
4k
views
Multiple instances of CRON_TZ inside a cron file (CentOS)
Is it possible to have multiple timezones in the /etc/crontab file, like below?
CRON_TZ=Europe/Paris
*/20 * * * * root /home/user/script.sh >/dev/null 2>&1
*/5 * * * * root /home/...
2
votes
2
answers
4k
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 ...
2
votes
9
answers
12k
views
CronTab: Not running my PHP scripts?
final edit: i have moved this to 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):
* * * * * GET https://abc.com/cron/...
2
votes
1
answer
3k
views
Cron jobs not working anymore
Cron jobs were working for months in the past but recently I had a high server load and now cron jobs aren't executing my php files (the same ones that were working before). When I check the cron log ...
1
vote
3
answers
27k
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
1
answer
2k
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
1
answer
340
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 ...
255
votes
10
answers
327k
views
When does `cron.daily` run?
When do entries in cron.daily (and .weekly and .hourly) run, and is it configurable?
I haven't found a definitive answer to this, and am hoping there is one.
I'm running RHEL5 and CentOS 4, but for ...
150
votes
5
answers
94k
views
Job scheduling using crontab, what will happen when computer is shutdown during that time?
I schedule some tasks using crontab.
What will happen if my computer is shutdown or turned off during the time when cron was scheduled to do something?
Does each missed cron job run after computer ...
101
votes
10
answers
251k
views
How to disable everything in crontab -l?
I just want to pause everything. Don't execute anything listed on crontab -l.
74
votes
5
answers
136k
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?
73
votes
6
answers
166k
views
Sending cron output to a file with a timestamp in its name
I have a crontab like this on a LAMP setup:
0 0 * * * /some/path/to/a/file.php > $HOME/cron.log 2>&1
This writes the output of the file to cron.log. However, when it runs again, it ...
67
votes
3
answers
304k
views
crontab running as a specific user
I need to run a script daily. The script should be run as a specific user (ex. user1) not as root. So I put the cron file at /etc/cron.d and put the user name in the line (2nd column). But it gives an ...
64
votes
7
answers
92k
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 ...
54
votes
4
answers
238k
views
How to check cron logs in Ubuntu
I went to /var/log/cron but this file is empty.
How to check if crontab is enabled or is running properly or not in ubuntu
thanks
52
votes
4
answers
37k
views
Should I edit /etc/crontab or run crontab -e as root?
I'm setting up regular system maintenance tasks which have to run as root. I plan to use the flavour of cron which comes with Ubuntu 14.04 LTS as the default.
I see the previous admin (who since left ...
44
votes
4
answers
13k
views
What's wrong with my cronjob syntax, I'm trying to use a backtick (`)?
Here's what I'd like to automate:
00 08 * * * psql -Uuser database < query.sql | mail [email protected] -s "query for `date +%Y-%m-%dZ%I:%M`"
Here's the error message:
/bin/sh: -c: line 0: ...
41
votes
2
answers
33k
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 ...
36
votes
16
answers
51k
views
Can't run AWS CLI from CRON (credentials)
Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
32
votes
1
answer
46k
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 ...
31
votes
6
answers
7k
views
Outgrowing cron: what's the next scheduler? [closed]
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 ...