Advertisement
bogdanborovskij

rotate

Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1. #!/bin/bash
  2. file=$(basename "$1" | cut -d. -f1)
  3. touch /etc/logrotate.d/$file
  4. echo "$1 {" > /etc/logrotate.d/$file
  5. echo "size=1M" >> /etc/logrotate.d/$file
  6. echo "rotate 5" >> /etc/logrotate.d/$file
  7. echo "missingok" >> /etc/logrotate.d/$file
  8. echo "compress" >> /etc/logrotate.d/$file
  9. echo "nomail" >> /etc/logrotate.d/$file
  10. echo "}" >> /etc/logrotate.d/$file
  11. crontab -l | { cat; echo "*/2 * * * * /usr/sbin/logrotate -f /etc/logrotate.d/$file"; } | crontab -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement