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.

Filter by
Sorted by
Tagged with
389 votes
7 answers
943k 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 ...
Eric Leschinski's user avatar
254 votes
10 answers
321k 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 ...
warren's user avatar
  • 18.6k
164 votes
14 answers
543k 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 ...
Pistos's user avatar
  • 3,133
160 votes
12 answers
323k 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
user3448600's user avatar
  • 1,599
148 votes
5 answers
92k 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 ...
seg.server.fault's user avatar
126 votes
11 answers
89k 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 ...
Tom's user avatar
  • 4,307
110 votes
6 answers
396k views

how to create a cron job that runs on the first day of month [duplicate]

There are fields on my server's control panel like this Minute - Hour - Day of month - Month - Day of the week - Command How can I create a cron job runs on first day of the month with this fields?...
Utku Dalmaz's user avatar
  • 1,349
106 votes
2 answers
47k 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 ...
shantanuo's user avatar
  • 3,609
100 votes
10 answers
247k views

How to disable everything in crontab -l?

I just want to pause everything. Don't execute anything listed on crontab -l.
Alex's user avatar
  • 8,521
82 votes
4 answers
153k views

Running Cron every 2 hours [duplicate]

I have the cron job as shown below, and wanted it to run every 2 hours, but it keeps running every 2 minutes. Can someone tell me where I'm going wrong? * */2 * * * /path-to-script
Helen's user avatar
  • 953
81 votes
3 answers
148k 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-...
Thomas L Holaday's user avatar
76 votes
4 answers
193k views

What is the correct syntax to run cron every 4 hours? [duplicate]

I have the following syntax (which I think is correcT?) but it runs the command every minute! * */4 * * * /cmd.sh
erotsppa's user avatar
  • 2,133
73 votes
5 answers
132k 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?
user avatar
72 votes
5 answers
73k views

How to send the output from a cronjob to multiple e-mail addresses?

In the beginning of a crontab file you could use the MAILTO instruction to indicate you want the output to be sent as an e-mail to an e-mail address. I would like to send the output to multiple ...
Boaz's user avatar
  • 2,249
72 votes
2 answers
103k views

How do I edit the crontab of another user on my linux server?

I have a user on my linux server who has sudo. I want to edit the crontab of another user. I'm new to this though and don't understand what the man pages are telling me yet. Man crontab tells me I ...
bflora's user avatar
  • 859
71 votes
6 answers
162k 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 ...
Philip Morton's user avatar
70 votes
3 answers
56k 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 ...
Stefan Lasiewski's user avatar
66 votes
3 answers
199k views

php cli memory limit

I am getting a memory error in a php cron job: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /opt/matrix/core/lib/DAL/DAL.inc on line 830 The ...
Ryan H's user avatar
  • 1,478
64 votes
3 answers
288k 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 ...
Sam Kong's user avatar
  • 903
63 votes
10 answers
72k 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?
user15336's user avatar
  • 783
63 votes
2 answers
122k views

How to run cron job on a specific hour every day?

What do I need to write in crontab to execute a script at 3pm every day?
john's user avatar
  • 1,025
63 votes
7 answers
89k 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 ...
Ben K.'s user avatar
  • 2,399
62 votes
2 answers
64k views

What user do scripts in the cron folders run as? (i.e. cron.daily, cron.hourly, etc)

If I put a script in /etc/cron.daily on CentOS what user will it run as? Do they all run as root or as the owner?
Kyle MacFarlane's user avatar
61 votes
3 answers
48k views

How to: 1 Cron Job every ODD minutes and 1 other every EVEN minutes?

I have 2 cron jobs, i want one of them to run every odd minute (1,3,5,7,9,11....57,59) and i want the other one to run every even minute (0,2,4,6,8,10,12...58) how can i do it in an easy way? (no ...
wabbajay's user avatar
  • 619
60 votes
6 answers
35k 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: ...
justinl's user avatar
  • 723
57 votes
3 answers
124k views

Do I need to refresh or restart anything after I add/update a crontab in Ubuntu Server 8.04?

When you change something in Apache you need to reload or restart apache. Does anything need to be refreshed or restarted in Ubuntu Server 8.04 after I add/update the crontab? Thanks a bunch for your ...
RayJamesFun's user avatar
56 votes
6 answers
73k 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 ...
Industrial's user avatar
  • 1,599
56 votes
4 answers
110k views

how to run cron job every 3 months?

What would be the crontab entry look like for a job that runs on the first day of every third month?
haim evgi's user avatar
  • 753
54 votes
4 answers
234k 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
user avatar
54 votes
7 answers
121k views

How to get e-mail from (failed) cron-jobs in Ubuntu?

I create cron-jobs in Ubuntu by placing the executable in one of /etc/cron.{daily,hourly,monthly,weekly}. There are lots of directories starting with cron: kent@rat:~$ ls -ld /etc/cron* drwxr-xr-x 2 ...
Deleted's user avatar
  • 1,832
52 votes
4 answers
36k 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 ...
marcv81's user avatar
  • 632
45 votes
13 answers
71k 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]?
Alexander Artemenko's user avatar
44 votes
5 answers
264k views

How to save and exit crontab -e?

How to save and exit crontab -e? i tried every method listed here and none works, i have a centos 5, vi comes by default with yum and i installed nano Solved just changed the default editor export ...
user's user avatar
  • 869
43 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: ...
Terry G Lorber's user avatar
43 votes
6 answers
49k 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 /...
user7321's user avatar
  • 1,016
43 votes
1 answer
62k views

Can you have a multi-line comment a crontab

Can I use the C++/Java-style /* */ syntax to multi-line comments in the crontab file?
belaz's user avatar
  • 595
40 votes
2 answers
32k 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 ...
EMP's user avatar
  • 5,172
39 votes
4 answers
83k views

How To Backup "crontab -e" Files?

I want to do a complete server backup. I already have my backup script copying all of the html/php files for the web app, and the mysql databases, placing them into a .tar.gz file. How can I add the ...
darkAsPitch's user avatar
  • 1,931
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 ...
binaryorganic's user avatar
33 votes
4 answers
75k views

crontab execution doesn't have the same environment variables as executing user

I ran my crontab job 0 2 */1 * * /aScript >aLog.log 2>&1 as a 'root' user, and however I found the env is different from env of the 'root' user, and therefore experiencing a different ...
Bamboo's user avatar
  • 435
32 votes
7 answers
60k views

How to change the time cron.daily is run in linux

I have a script in cron.daily that runs at a certain time every morning. I need to change the time that it is run. How do I change the time cron.daily runs the scripts?
user avatar
32 votes
8 answers
28k views

Can cron write job output to a log *by default* (instead of mail)?

We all know the right way to handle output from cron jobs is to redirect it to a file: 0 * * * * /bin/date >> /var/log/date.log 2>&1 However, sometimes admins are lazy, forgetful, or ...
Brad's user avatar
  • 422
31 votes
8 answers
29k views

Robustly disabling specific cron.{hourly,daily,weekly} script

On various systems that I administer, there are cron scripts that get run via the commonly-used /etc/cron.{hourly,daily,weekly} layout. What I want to know is whether there's any common 'disable this ...
benizi's user avatar
  • 462
31 votes
2 answers
5k views

Why did my cron job run this month?

Today is November 1st 2016 or in (unambiguous) numerals, 2016-11-01. I have a user cron job set up like this: # m h dom mon dow command 33 3 1 */2 * /home/user/... It is supposed to run ...
comfreak's user avatar
  • 1,501
30 votes
1 answer
45k 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 ...
Bart B's user avatar
  • 3,487
30 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 ...
Cakemox's user avatar
  • 25.4k
29 votes
4 answers
100k views

What could cause "Permission denied" for command `crontab -e`?

Here's some output that I hope is helpful: nick@home-sv-1:~$ crontab -e /var/spool/cron/crontabs/nick: Permission denied nick@home-sv-1:~$ echo $EDITOR emacs nick@home-sv-1:~$ ls /var/spool/cron/...
Nick Bolton's user avatar
  • 5,136
28 votes
2 answers
20k views

Crontab maximum command length

Is there a limit of characters a command in a crontab could be ? I have a crontab with a 178 characters command and it seems to be truncated at 164 when executed. I can tell this number from the e-...
Ponytech's user avatar
  • 934
27 votes
5 answers
30k views

Crond offset five minute schedule

Is it possible to offset a cron script set to run every 5 minutes? I have two scripts, script 1 collects some data from one database and inserts it into another, script 2 pulls out this data and a ...
user avatar
26 votes
2 answers
120k views

How to configure cron job to run every 2 days at 11PM [duplicate]

I have a centos server and I want to run a job on it at 11PM every 2 days, how do I do that?
fred basset's user avatar

1
2 3 4 5
40