There is a way to monitor your system usage and log to a file easily — with
On my Ubuntu it can be installed with
sudo apt-get install atop
It can be started as a
top command — it’s output almost the same.
But the most interesting feature is that it starts a daemon that logs system usage into a file that can be viewed later on. It stores system usage log for one month by default.
If you run this
ps aux|grep atop, it will output something like
/usr/bin/atop -a -w /var/log/atop/atop_20190714 600.
It means that it logs to
/var/log/atop/atop_20190714 and does it every 600 seconds.
You can alter the config, which can be located in several places depending on your system:
In my config, I decided to change log interval to 60 seconds by replacing 600 to 60 and running
service atop restart.
ps aux|grep atop says
/usr/bin/atop -a -w /var/log/atop/atop_20190714 60.
You can browse logs for a day with command
atop -r /var/log/atop/atop_20190714 and go forward in time by pressing
T makes it go backward.