54

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

jbobbins
  • 155
  • 1
  • 4
  • This same question answered on below link [answer from another trail](https://askubuntu.com/questions/624701/where-are-cron-logs-stored-on-ubuntu-14-04/1384537#1384537) https://askubuntu.com/questions/624701/where-are-cron-logs-stored-on-ubuntu-14-04/1384537#1384537 – Mahesh More Dec 31 '21 at 08:43

4 Answers4

96
  1. modify rsyslog config: open /etc/rsyslog.d/50-default.conf,remove # before cron.*
  2. restart rsyslog service: sudo service rsyslog restart
  3. restart cron service: service cron restart

now you can check cron log from file /var/log/cron.log

Xiao
  • 1,061
  • 1
  • 7
  • 5
  • 2
    This is great. Saves searching through the syslog – phocks Jul 10 '16 at 01:56
  • 1
    Best answer so far. – azeem Oct 04 '16 at 10:45
  • 3
    Check `/etc/rsyslog.conf` if you're on an older system or if there's nothing in `/etc/rsyslog.d` – Wimateeka May 07 '19 at 17:32
  • 1
    @Sean We can also restart the Cron service via `sudo service cron restart` apart from that your answer worked liked a Charm!! – Hussain7 Nov 11 '19 at 06:07
  • This worked for me, but I additionally had to install `apt install rsyslog -y` first. Then there was no file in `rsyslog.d` as Wimateeka mentioned, but I modified `rsyslog.conf` directly. – phi Jan 30 '22 at 10:39
44

If you want to know if it's running you can do something like sudo systemctl status cron or ps aux | grep cron.

If you want to know if your cron jobs are running, check /var/log/syslog with the process name cron. For example:

Apr 26 21:17:01 example CRON[18055]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
David
  • 3,555
  • 22
  • 17
  • Thanks buddy , i searc hed internet and they were sying the log file is /var/log/cron or cron.log , what is that file for –  Apr 28 '10 at 01:19
  • 1
    It all depends on how syslog is configured. Some distributions/Unix will split everything out, other dump just about everything into one file. – David Apr 30 '10 at 17:09
  • Just for the record: Any `systemctl` attempts will not work in (unprivileged) docker containers. Try the answer from Sean then. – phi Jan 30 '22 at 10:41
25

By default the cron log in Ubuntu is located at /var/log/syslog. Use the below command to check the cron entries in this file.

grep cron /var/log/syslog

  • 6
    Case insensitive search yields more comprehensive results. `grep -i cron /var/log/syslog` – Henry Oct 15 '19 at 18:04
15

New information for 2020: cron is now a systemctl service, so you can have the logs of cron / anacron with:

journalctl -u cron.service

if you did install anacron, it is the same with:

journalctl -u anacron.service

(anacron is for desktop, when your computer is not garanteed to be always on. It enforce that even if your computer is down at 5'00, daily jobs are run when the computer has started up).

jehon
  • 261
  • 2
  • 4
  • journalctl -u cron.service No journal files were found.<- -on Ubuntu 20.04 WSL2 – relipse Dec 31 '20 at 21:31
  • @relipse: I did try again, and it did work. Perhaps something is missing in your setup or in my explanation. If you find out, please complete this answer – jehon Jan 25 '21 at 12:25