61

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 ?

1 Answer 1

91

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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .