GoAdmio Command Line: logrotate with /go/logrotate

Web server logs grow all the time. A tool called logrotate renames old logs, starts fresh ones, and deletes the oldest. /go/logrotate decides how that is done for the web server logs under /var/log: The command writes the setting into the logrotate configuration of Apache and Nginx, and records the choice in GoAdmio's configuration database. It works on whichever of those configurations already exist on the server. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Rotate daily, keep 7 old logs
/go/logrotate 1

# Go back to the default schedule
/go/logrotate

Arguments

Position Argument Required Default Notes
1 1 No Default rotation Only the exact value 1 turns on daily rotation. Any other value, including 7, daily, or 0, selects default rotation.

There are no --option value pairs.

Examples

# Keep a week of daily logs
/go/logrotate 1

# Return to the system's normal schedule
/go/logrotate

# Test the new rules without changing anything (dry run)
logrotate -d /etc/logrotate.d/nginx

# Force a rotation now to see it work
logrotate -f /etc/logrotate.d/nginx

Output

The command prints nothing. To check the result:

# The saved choice: 1 means daily, 7 means default
sqlite3 /var/lib/sqlite/config.db "select ApacheLogRotate from Config"

# The rules written for your web server
cat /etc/logrotate.d/nginx
cat /etc/logrotate.d/apache2 # Debian and Ubuntu
cat /etc/logrotate.d/httpd # AlmaLinux, Rocky, CentOS, Red Hat, Fedora

Mode Value saved in the database Rules written
Daily 1 daily and rotate 7
Default 7 Neither line, so the system defaults are used

See the full reference at /go/logrotate and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *