Where to find the Crontab logs in CentOS

223,485

Cron logs on CentOS 6 are located in /var/log/cron by default. This only logs the execution of commands, not the results or exit statuses. The output of the executed command goes to the user's mail by default (root's mail in this case). An alternate email can be specified by the MAILTO variable inside of the crontab.

You should look at adjusting logrotate rules, instead of your custom cron, which already handles deletion of /var/log/secure logs.

Share:
223,485

Related videos on Youtube

Prime
Author by

Prime

I'm @ Non-Pro Application Development IBM WebSphere Application Server & Oracle WebLogic Server Self-Learner and internet enthusiast. I know what stopped me... U know what ? It never stopping me again.

Updated on September 18, 2022

Comments

  • Prime
    Prime almost 2 years

    First of all I'm using CentOS

     [root@a etc]# cat system-release
     CentOS release 6.5 (Final)
    
    [root@a cron.daily]# ps -ef | grep cron
    root       982     1  0 Jun14 ?        00:01:15 crond
    root      5692  5441  0 00:49 pts/0    00:00:00 grep cron
    [root@a cron.daily]#
    

    And I'm running out of my resources, so I want to delete the old log files.In this case i would like to delete the old secure logs which are almost more than 100MB's in size, So i gave the below crontab entries for root user.

    [root@a etc]# crontab -l
    0 1 * * * find /var/log -name "secure-*" -mtime +5 -exec rm {} \;
    [root@a etc]#
    

    After very few days later i came to know this crontab entry doesn't work and still i see old files.

    [root@a log]# find /var/log -name "secure-*"
    /var/log/secure-20141214
    /var/log/secure-20141107
    /var/log/secure-20141130
    /var/log/secure-20141221
    [root@a log]#
    

    Later i tried to search for the crontab logs under /etc/crontab.daily directory and not found any relevant results. Where to find the crontab logs and how to know whether the crontab is running successfully or not ?

  • Junior Mayhé
    Junior Mayhé about 8 years
    You can use run-parts stackoverflow.com/questions/4984725/how-to-test-cron-job to test cron and check the commands output at /var/spool/mail/(user) superuser.com/questions/306163/…