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
69
votes
3 answers

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 to a central Nagios sever. This send_nsca script…
Stefan Lasiewski
  • 23,667
  • 41
  • 132
  • 186
69
votes
6 answers

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 overwrites whatever was previously in the file. How can I get cron…
Philip Morton
  • 813
  • 1
  • 6
  • 7
65
votes
3 answers

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 applicable parts of the crontab are: $ sudo crontab -u…
Ryan H
  • 1,468
  • 3
  • 15
  • 19
63
votes
10 answers

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
  • 783
  • 1
  • 5
  • 8
63
votes
2 answers

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
  • 1,025
  • 3
  • 9
  • 15
62
votes
8 answers

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 save, unlike crontab -e -- so a stray character can…
Ben K.
  • 2,379
  • 4
  • 18
  • 15
62
votes
3 answers

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 error saying that the command is not found. I…
Sam Kong
  • 883
  • 1
  • 8
  • 10
61
votes
2 answers

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
  • 807
  • 2
  • 9
  • 12
60
votes
3 answers

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 scripting - just cron job rules)
wabbajay
  • 609
  • 1
  • 5
  • 3
59
votes
6 answers

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: From: Cron Daemon Subject: Cron …
justinl
  • 713
  • 1
  • 6
  • 9
57
votes
3 answers

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 help.
RayJamesFun
  • 573
  • 1
  • 4
  • 4
56
votes
4 answers

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
  • 753
  • 1
  • 10
  • 15
54
votes
7 answers

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 root root 4096 2009-06-06 18:52…
Deleted
  • 1,832
  • 8
  • 23
  • 31
54
votes
6 answers

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 executed and not only when things go wrong. Is it…
Industrial
  • 1,579
  • 6
  • 24
  • 37
54
votes
4 answers

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
John