Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Configuring logrotate without root access (per user log rotation)

Writer Matthew Harrington

How best can logrotate be configured, on a per-user basis, to rotate files in the home directory of the user, under control of a per-user crontab -e?

1 Answer

Try this procedure:

  1. create /home/user/logrotate folder

    mkdir /home/user/logrotate
  2. create /home/user/logrotate/my.conf configuration file with logrotate directive as you need

  3. create /home/user/logrotate/cronjob to run logrotate every day at 2:30 AM (this is an example)

    30 2 * * * /usr/sbin/logrotate -s /home/user/logrotate/status /home/user/logrotate/my.conf > /dev/null 2>&1
  4. check your configuration file syntax:

    logrotate -d /home/user/logrotate/my.conf
  5. configure crontab to run logrotate(Warning: This removes existing entries in your crontab. Use crontab -e to manually add the line from step 3 to an existing crontab):

    crontab /home/user/logrotate/cronjob 

After this last command, logrotate will rotate file as described in /home/user/logrotate/my.conf and save log file status in /home/user/logrotate/status.

Use:

crontab -r # remove crontab activities for user
crontab -l # to list crontab activity for user
crontab -e # edit user crontab entries

Here is logrotate and crontab man page.

6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy