# Log Rotation
| | In information technology, **Log Rotation** is an automated process used in system administration in which log files are compressed, moved (archived), renamed or deleted once they are too old or too big . New incoming log data is directed into a new fresh file. |
|-|-|
| | wikipedia:: [Log rotation](https://en.wikipedia.org/wiki/Log_rotation) |
## Keeping log files small
- [linux - How to truncate the log file size without losing recent logs? - Server Fault](https://serverfault.com/questions/1101835/how-to-truncate-the-log-file-size-without-losing-recent-logs)
```
tail -c 1M /tmp/myfile > /tmp/dzqxH4ZMiSQb91uMMMgPhsgmpnc && rm /tmp/myfile && mv /tmp/dzqxH4ZMiSQb91uMMMgPhsgmpnc /tmp/myfile
```
## Logrotate
[Rotating Logs With Logrotate in Linux | Baeldung on Linux](https://www.baeldung.com/linux/rotating-logs-logrotate?cmdf=logrotate)
[How To Configure Logging and Log Rotation in Nginx on an Ubuntu VPS | DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps)