Skip to content

Instantly share code, notes, and snippets.

@kvn1234
Last active June 26, 2017 00:05
Show Gist options
  • Save kvn1234/7b28727e3b482e1c7fe83d0879ab8e5d to your computer and use it in GitHub Desktop.
Save kvn1234/7b28727e3b482e1c7fe83d0879ab8e5d to your computer and use it in GitHub Desktop.
Create logrotater - linux
**** create file: sudo vi /etc/logrotate.d/descriptive_name_here
**** code example, e.g., this one is symfony:
/var/www/current/var/logs/prod.log {
su ubuntu www-data
create 0664 ubuntu www-data
daily
missingok
rotate 14
compress
}
**** IMPORTANT: first line is path to application's log, so change to match
**** change "su ubuntu www-data" to user/group application runs under, i.e., www-data www-data for nginx
**** test config with sudo logrotate --d /etc/logrotate.d/file_name_from_above
**** option force rotation: sudo logrotate --force /etc/logrotate.d/file_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment