Logrotate is crontab script who execute every day.
You can look into thos directory for view any exemples : /etc/logrotate.d/
$ sudo ls -la /etc/logrotate.d/
drwxr-xr-x 2 root root 4096 Oct 25 15:50 .
drwxr-xr-x 115 root root 4096 Oct 22 06:54 ..
-rw-r--r-- 1 root root 126 Feb 7 2015 apport
-rw-r--r-- 1 root root 173 Apr 10 2014 apt
-rw-r--r-- 1 root root 79 Feb 18 2014 aptitude
-rw-r--r-- 1 root root 232 Mar 7 2014 dpkg
-rw-r--r-- 1 root root 609 Jan 8 2015 landscape-client
-rw-r--r-- 1 root root 158 Oct 25 15:50 memory_usage
-rw-r--r-- 1 root root 346 Feb 11 2015 nginx
-rw-r--r-- 1 root root 94 Nov 25 2014 ppp
-rw-r--r-- 1 root root 126 Jan 14 2014 redis-server
-rw-r--r-- 1 root root 515 Dec 4 2013 rsyslog
-rw-r--r-- 1 root root 178 Feb 28 2014 ufw
-rw-r--r-- 1 root root 177 Dec 6 2013 unattended-upgrades
-rw-r--r-- 1 root root 122 Apr 11 2014 upstart
$ sudo cat /etc/logrotate.d/nginx
/var/log/nginx/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
[ -s /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
endscript
}
$ sudo vi /etc/logrotate.d/memory_usage
/data/srv/deploy/log/memory_usage.log {
daily
missingok
notifempty
create 700 deploy deploy
rotate 30
compress
su deploy deploy
}
Tadam !!
You can test it with this command : sudo logrotate --force /etc/logrotate.d/memory_usage