I am running Rails 5 on Ubuntu 14.04. Is there a way to rotate my logs without relying on the logrotate Linux system? I have it...
myuser@myapp:~$ cat /etc/logrotate.d/myapp
/home/rails/myapp/log/*.log {
daily
missingok
rotate 2
compress
delaycompress
notifempty
copytruncate
}
but my magazines never spin. That's how they bloated ...
myuser@myapp:~$ ls -al /home/rails/myapp/log/
total 3958356
drwxr-xr-x 2 rails rails 4096 Jul 3 22:31 .
drwxr-xr-x 15 rails rails 4096 Sep 21 17:21 ..
-rw-rw-r-- 1 rails rails 0 Jun 22 10:22 development.log
-rw-rw-r-- 1 rails rails 14960 Jun 1 22:39 development.log.1
-rw-rw-r-- 1 rails rails 0 Oct 22 2016 .keep
-rw-r--r-- 1 rails rails 198362787 Oct 31 16:28 production.log
-rw-r--r-- 1 rails rails 8615654 Jul 3 22:31 production.log.1
-rw-r--r-- 1 rails rails 640621243 Jun 29 13:16 production.log.2.gz
-rw-rw-r-- 1 rails rails 2856792698 Oct 31 17:12 sidekiq.log
-rw-rw-r-- 1 rails rails 348853619 Jul 3 22:31 sidekiq.log.1
-rw-rw-r-- 1 rails rails 0 Jul 3 22:31 test.log
-rw-rw-r-- 1 rails rails 54246 Jul 3 22:31 test.log.1
Is there any other way to make the logs rotate or is there a way to fix the configuration I turned on?
Edit: Here is a cron script that installs
myuser@myapp:~$ cat /etc/cron.daily/logrotate
#!/bin/sh
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
[ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
Edit: In a comment, I tried adding this to the config / environment / production.rb file ...
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, 50 * 1024 * 1024)
but magazines are getting bigger without a turn.
source
share