# Best method to redirect logs to independant storage in Linux

**URL:** <https://forum.storj.io/t/best-method-to-redirect-logs-to-independant-storage-in-linux/8039>\
**Category:** Node Operators\
**Tags:** docker, linux, storagenode\
**Created:** [July 8, 2020, 9:19pm UTC](https://forum.storj.io/t/best-method-to-redirect-logs-to-independant-storage-in-linux/8039 "2020-07-08T21:19:27Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![baker](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/baker/32/6110_2.png) [@baker](https://forum.storj.io/u/baker)\
**Post date:** [May 17, 2023, 3:54pm UTC](https://forum.storj.io/t/best-method-to-redirect-logs-to-independant-storage-in-linux/8039/10 "2023-05-17T15:54:16Z")

</div>

Hi phillipe,

This is easy to do with logrotate since you can use wildcards to define your paths and files. I placed a logrotate config file in `/etc/logrotate.d/` called `storagenode` . It is a plain text file. My logrotate config file is as follows. Don’t include comments in your config file (there is an uncommented version below).

```bash
/mnt/logs-usb/storj*/storagenode*.log {
#the wildcard (*) characters tell logrotate to look in any subfolder that
#begins with storj, and rotate any log that starts with storagenode
#and has a .log extension
        su user group #run as specific user and group, this may not be necessary for you
        weekly #rotates logs weekly
        maxsize 200M #rotate logs if log file is greater than 200 MB even if it has been less than a week
        rotate 52 #keep 52 previous log files
        dateext #append date to rotated log file extensions
        dateformat -%Y%m%d #use this date format for rotated logs
        compress #compress rotated logs
        delaycompress #leave the most recent rotate log uncompressed until the next cycle
        missingok #do not error out if log file is missing
        notifempty #do not rotate empty log files
        copytruncate #copies rotated log and truncates original
}

```

> **Uncommented version**
>
> ```plaintext
> /mnt/logs-usb/storj*/storagenode*.log {
> su user group
> weekly
> maxsize 200M
> rotate 52
> dateext
> dateformat -%Y%m%d
> compress
> delaycompress
> missingok
> notifempty
> copytruncate
> }
> 
> ```

You can get more information about different log rotate options here  
[https://www.man7.org/linux/man-pages/man8/logrotate.8.html](https://www.man7.org/linux/man-pages/man8/logrotate.8.html)

---

_[View the full topic](https://forum.storj.io/t/best-method-to-redirect-logs-to-independant-storage-in-linux/8039)._
