↑ ↓ select, Enter open, Esc close

Force log rotation immediately

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
root@server
logrotate -vf /etc/logrotate.d/nginx

-f forces the rotation regardless of the conditions in the configuration, and -v shows each step. Useful for testing a new configuration for real or for shrinking an oversized log right away. This also runs the postrotate scripts, which usually reload a service.

Note: Depending on the rotate value, the oldest rotated file is dropped. Check beforehand with logrotate -d what would happen.

Also searched as

  • rotate log now
  • run logrotate manually
  • rotate log file immediately
  • logrotate force

Related one-liners

All in Logs

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.