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.

For information about the most common cron issues and how to fix them, see Why is my crontab not working and how can I troubleshoot it.

1957 questions
380
votes
7 answers

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 not answered below then the answers will help you…
Eric Leschinski
  • 4,211
  • 4
  • 21
  • 27
251
votes
10 answers

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 other distros/platforms would be great, too.
warren
  • 18,369
  • 23
  • 84
  • 135
162
votes
14 answers

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 cronned. I am aware that I can set up a * * * * *…
Pistos
  • 3,093
  • 6
  • 22
  • 21
158
votes
12 answers

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
  • 1,579
  • 2
  • 13
  • 12
147
votes
5 answers

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 is turned on, or are missed jobs for that day…
seg.server.fault
  • 1,907
  • 4
  • 16
  • 11
125
votes
11 answers

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 concurrency problem - i.e. the script execution needs to…
Tom
  • 4,277
  • 11
  • 42
  • 52
108
votes
6 answers

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

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
  • 1,329
  • 2
  • 13
  • 18
106
votes
2 answers

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 to add it to daily cron.
shantanuo
  • 3,579
  • 8
  • 49
  • 66
97
votes
10 answers

How to disable everything in crontab -l?

I just want to pause everything. Don't execute anything listed on crontab -l.
Alex
  • 8,471
  • 26
  • 75
  • 99
82
votes
4 answers

Running Cron every 2 hours

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
  • 953
  • 1
  • 6
  • 7
81
votes
3 answers

What does * * * * * (five asterisks) in a cron file mean?

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-wildcards mean to (Solaris 8) cron? The betting here is…
Thomas L Holaday
  • 1,353
  • 4
  • 16
  • 19
75
votes
4 answers

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

I have the following syntax (which I think is correcT?) but it runs the command every minute! * */4 * * * /cmd.sh
erotsppa
  • 2,113
  • 6
  • 23
  • 24
73
votes
5 answers

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?
user56548
71
votes
2 answers

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 can use this format for the crontab…
bflora
  • 849
  • 1
  • 6
  • 3
70
votes
5 answers

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 addresses. Is it possible (and how) to specify multiple…
Boaz
  • 2,229
  • 5
  • 20
  • 15
1
2 3
99 100