Using logrotate as a non-root user

There may be situations when you need to use logrotate without having root
access to the server that you’re dealing with. In these situations you can
point logrotate at a state file in your home directory.

First, create your logrotate configuration file with something like:

/var/log/messages {
rotate 5

and then save to ~/logrotate.conf. Next, touch your state file:

touch ~/.logrotate-state

and then you can run logrotate either via SSH or via cron:

/sbin/logrotate —state ~/.logrotate-state ~/.logrotate.conf

This is useful for providers that don’t give access to logrotate directly
but the binary is present to use.