ruby - How do you use logrotate with output redirect? -
i'm running ruby script logs http traffic stdout. since wanted logs persistent, redirected output log file ruby ruby_script.rb >> /var/log/ruby_script.log. however, logs getting large wanted implement logrotate using following:
"/var/log/ruby_script.log" { missingok daily rotate 10 dateext } however, after running logrotate --force -v ruby_script "ruby_script" name of logrotate.d configuration file, no new file created script write to, , writes rotated file instead. i'm guessing behavior happens because file descriptor passed >> sticks file regardless of moving it, , unrelated filename after first call. thus, question is, correct way achieve functionality i'm looking for?
take @ option copytruncate.
from man logrotate:
copytruncate: truncate original log file 0 size in place after creating copy, instead of moving old log file , optionally creating new one. can used when program cannot told close logfile , might continue writing (appending) previous log file forever. note there small time slice between copying file , truncating it, logging data might lost. when option used, create option have no effect, old log file stays in place.
Comments
Post a Comment