Quantcast
Channel: myVesta
Viewing all articles
Browse latest Browse all 285

Linux tutorials • Configuring atop with custom log Interval and automated log cleanup

$
0
0
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:

Code:

apt updateapt install -y atop
Configuring 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
Update the Atop default configuration

Code:

sed -i “s#LOGINTERVAL=.*#LOGINTERVAL=10#g” /etc/default/atopif ! grep -q ‘LOGINTERVAL’ /etc/default/atop; thenecho ‘LOGINTERVAL=10’ >> /etc/default/atopfi
Reload and restart Atop

Code:

systemctl daemon-reloadsystemctl 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:

Code:

crontab -l | { cat; echo “9 4 * * * find /var/log/atop/ -mtime +2 -delete”; } | crontab -
Viewing Logs at a Specific Time

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



Viewing all articles
Browse latest Browse all 285

Trending Articles