# Logrotate config for per-user nginx log files

**URL:** https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459
**Category:** Feature Requests and Roadmap Discussion
**Tags:** feature-request
**Created:** [August 7, 2019, 5:27pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459 "2019-08-07T17:27:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![griznog](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/griznog/32/39_2.png) [@griznog](https://discourse.openondemand.org/u/griznog)
#### Post date: [August 7, 2019, 5:27pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459/1 "2019-08-07T17:27:08Z")

</div>

HI,

I noticed today (when the log files filled the /var/log mount) that the per-user nginx log files in `/var/log/ondemand-nginx/$USER/` are not being rotated. I tried a few different approaches in `/etc/logrotate.d/ondemand-nginx` but I never figured out how to use a signal to get the user nginx and Passenger processes to let go of the old log files. So I settled on this:

```auto
/var/log/ondemand-nginx/*log /var/log/ondemand-nginx/*/*log {
    create 0644 ondemand-nginx ondemand-nginx
    daily
    rotate 10
    copytruncate
    missingok
    notifempty
    compress
}

```

My feature request is for a better logrotate config than the one I came up with.

Best,

griznog

---

<div class="post-metadata">

### Author: ![tdockendorf](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/tdockendorf/32/202_2.png) [@tdockendorf](https://discourse.openondemand.org/u/tdockendorf)
#### Post date: [August 7, 2019, 6:09pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459/2 "2019-08-07T18:09:09Z")

</div>

This is what we use at OSC:

```
/var/log/ondemand-nginx/*/access.log /var/log/ondemand-nginx/*/error.log {
  compress
  copytruncate
  missingok
  notifempty
  rotate 52
  weekly
}
```

---

<div class="post-metadata">

### Author: ![griznog](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/griznog/32/39_2.png) [@griznog](https://discourse.openondemand.org/u/griznog)
#### Post date: [August 7, 2019, 11:43pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459/3 "2019-08-07T23:43:04Z")

</div>

Any chance this could go into the upstream distribution to replace the current version that ships in the rpms?

Off-topic: I wanted to ‘like’ your version, but discourse uses a heart which seemed like more commitment than I’m ready for right now. I mean, I just met your `ondemand-nginx` logrotate config and it’d feel ok to give a thumbs up but we need to get to know each other better before a heart is appropriate. I’m old-fashioned that way.

---

<div class="post-metadata">

### Author: ![tdockendorf](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/tdockendorf/32/202_2.png) [@tdockendorf](https://discourse.openondemand.org/u/tdockendorf)
#### Post date: [August 8, 2019, 1:49pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459/4 "2019-08-08T13:49:27Z")

</div>

I’ve opened pull request to include a basic logrotate config for OnDemand RPMs.

> <https://github.com/OSC/ondemand/pull/53>

---

<div class="post-metadata">

### Author: ![efranz](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/efranz/32/27_2.png) [@efranz](https://discourse.openondemand.org/u/efranz)
#### Post date: [October 24, 2019, 6:43pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459/5 "2019-10-24T18:43:18Z")

</div>

FYI this is currently apart of ondemand in the latest 1.6 patch release

---

<div class="post-metadata">

### Author: ![westburg.2](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@westburg.2](https://discourse.openondemand.org/u/westburg.2)
#### Post date: [May 26, 2022, 4:11pm UTC](https://discourse.openondemand.org/t/logrotate-config-for-per-user-nginx-log-files/459/6 "2022-05-26T16:11:39Z")

</div>


