Installation
Update your package lists and install Atop:
Code: Select all
apt update
apt install -y atop
We will set the logging interval to 10 seconds.
Update the Atop systemd service file
Code: Select all
sed -i “s|Environment=LOGINTERVAL=.*|Environment=LOGINTERVAL=10|g” /lib/systemd/system/atop.service
sed -i “s|${LOGINTERVAL}|10|g” /lib/systemd/system/atop.service
if ! grep -q ‘LOGINTERVAL’ /lib/systemd/system/atop.service; then
INIVAL=‘Environment=“LOGINTERVAL=600”’
sed -i “s|Service|[Service]\n$INIVAL|g” /lib/systemd/system/atop.service
fi
Code: Select all
sed -i “s#LOGINTERVAL=.*#LOGINTERVAL=10#g” /etc/default/atop
if ! grep -q ‘LOGINTERVAL’ /etc/default/atop; then
echo ‘LOGINTERVAL=10’ >> /etc/default/atop
fi
Code: Select all
systemctl daemon-reload
systemctl restart atop
Add a cron job to delete Atop logs older than 2 days. This job runs daily at 4:09 AM:
Code: Select all
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: Select all
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.