This guide provides step-by-step instructions to install Atop, configure it to log at a custom interval, and set up automatic log file cleanup.
Installation
Update your package lists and install Atop:
Configuring Atop
We will set the logging interval to 10 seconds.
Update the Atop systemd service file
Update the Atop default configuration
Reload and restart Atop
Setting Up Automatic Log Cleanup
Add a cron job to delete Atop logs older than 2 days. This job runs daily at 4:09 AM:
Viewing Logs at a Specific Time
To view Atop logs for a specific minute, for example, 13:40:
Installation
Update your package lists and install Atop:
Code:
apt updateapt install -y atop
We will set the logging interval to 10 seconds.
Update the Atop systemd service file
Code:
sed -i “s|Environment=LOGINTERVAL=.*|Environment=LOGINTERVAL=10|g” /lib/systemd/system/atop.servicesed -i “s|${LOGINTERVAL}|10|g” /lib/systemd/system/atop.serviceif ! grep -q ‘LOGINTERVAL’ /lib/systemd/system/atop.service; thenINIVAL=‘Environment=“LOGINTERVAL=600”’sed -i “s|Service|[Service]\n$INIVAL|g” /lib/systemd/system/atop.servicefi
Code:
sed -i “s#LOGINTERVAL=.*#LOGINTERVAL=10#g” /etc/default/atopif ! grep -q ‘LOGINTERVAL’ /etc/default/atop; thenecho ‘LOGINTERVAL=10’ >> /etc/default/atopfi
Code:
systemctl daemon-reloadsystemctl restart atop
Add a cron job to delete Atop logs older than 2 days. This job runs daily at 4:09 AM:
Code:
crontab -l | { cat; echo “9 4 * * * find /var/log/atop/ -mtime +2 -delete”; } | crontab -
To view Atop logs for a specific minute, for example, 13:40:
Code:
atop -Af1 -b 13:40 -r /var/log/atop/atop_20241126
- Use ‘t’ to go forward in time.
- Use ‘T’ to go back in time.
- To analyze specific times, press ‘b’ and enter the desired time.
Statistics: Posted by isscbta — Wed Nov 27, 2024 4:29 pm