Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Do not rm_log_files

28,290 views

Published on

MTS vol.2

Published in: Engineering
  • Sex in your area is here: ♥♥♥ http://bit.ly/2F7hN3u ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❶❶❶ http://bit.ly/2F7hN3u ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Do not rm_log_files

  1. 1. Do not ‘rm’ log files Part time CTO Masato Bito
  2. 2. Experience like this? Daemon outputs lots of data into a log file Disk becomes full Service stops(no space left on device) ‘rm’ a huge log file(to get free space) still disk full Restart a daemon(stuck here, nothing comes up) Ctrl-C doesn’t work kill -KILL doesn’t work
  3. 3. “Wrong” way to remove a log file
  4. 4. “Exact” way to remove a log file
  5. 5. What is ‘rm’? ‘rm’ removes files
  6. 6. What does ‘rm’ do? ‘rm’ does “not” remove any file ‘rm’ removes links
  7. 7. What is a “link”? A link on Unix system refers a file itself link: /var/log/apache2/access_log inode: 8823836
  8. 8. Who removes a file? Kernel Kernel provides only unlink(2) system call man 2 unlink
  9. 9. When is a file removed? When you can remove a file safely Nothing refers a file
  10. 10. Garbage collection Method to remove objects not used Various algorithm
  11. 11. Reference counting One of garbage collection algorithms Each object counts the number of references An object would be removed when references became “0”
  12. 12. What was happened /var/log/apache2/access_log httpd 8823836 log file references: 2
  13. 13. What was happened rm /var/log/apache2/access_log 8823836 log file references: 1 httpd
  14. 14. What was happened service httpd restart 8823836 log file references: 0 httpd stuck start removing
  15. 15. Exact way mv access_log access_log2 /var/log/apache2/access_log2 httpd 8823836 log file references: 2
  16. 16. Exact way service httpd restart 8823836 log file references: 1 httpd /var/log/apache2/access_log2 8823837 log file references: 2 /var/log/apache2/access_log
  17. 17. Exact way rm access_log2 8823836 log file references: 0 httpd /var/log/apache2/access_log2 8823837 log file references: 2 /var/log/apache2/access_log stuck start removing
  18. 18. log rotation mv access_log access_log.2 kill -HUP <pid> gzip access_log.2
  19. 19. Wait
  20. 20. kill -HUP Hang Up Signal?
  21. 21. Next: Why SIGHUP is used to reload files
  22. 22. Thanks

×