5

I installed atop version 1.26 on Ubuntu 12.04 server. By default, its sampling interval is 10 minutes. How can I change to 1 minute?

Also, how can I set the log path? Currently the logs are at /var/log/, but I notice that atop added a folder /var/log/atop/ (empty). How can I set the logs to be saved in this folder?

Raptor
  • 305
  • 2
  • 5
  • 13
  • 1
    Adding this here since I have been searching for this *forever*, and this question has popped up consistently: On *Ubuntu*, the log retention time for atop logs is "hard"-coded into atop init.d script, you can find the line by searching for `find` within the script (default should be `+28`). – dualed Jan 18 '18 at 17:12

5 Answers5

7
  1. Edit the file /etc/default/atop
  2. SET INTERVAl=60
  3. SET LOGPATH="/ur-desired-path", in this case LOGPATH="/var/log/atop"
  4. Restart the atop service systemctl restart atop.service

P.S. In Centos 7 I have atop's config file in /etc/sysconfig/atop.

agc
  • 7,045
  • 3
  • 23
  • 53
Moh .S
  • 171
  • 1
  • 5
  • 1
    Content of /etc/default/atop: "# this file is no longer used and will be removed in a future release". Would you know where is the new file? – toliveira Sep 02 '20 at 23:48
  • 1
    According to atop [manpage](https://linux.die.net/man/1/atop), it is now configurable using `/etc/atoprc` or `~/.atoprc`. `man atoprc` list configuration options. – Darkfish Sep 09 '20 at 01:57
  • 1
    Update: `atoprc` doesn't control log interval of the background job that saves these logfiles. Instead it only controls the default for interactive session. So it seems like one has to edit the file `/usr/share/atop/atop.daily` or wherever an equivalent file is on a given system. – Darkfish Sep 11 '20 at 03:55
  • 1
    Thanks for noting the different config path for CentOS, you'd think they'd mention this in the man pages.. – MSpreij Jun 29 '21 at 09:22
4

On Ubuntu 18.04 you'd change the file /usr/share/atop/atop.daily and change the line:

INTERVAL=600

to:

INTERVAL=60 
AdminBee
  • 21,637
  • 21
  • 47
  • 71
2

On Ubuntu 16.04 you can change the sampling interval in the /etc/default/atop file.

To change it to sample once a minute, edit the the file and set INTERVAL=60

You can also edit the location of the log files by setting the LOGPATH variable.

After editing the defaults, restart the atop daemon with this command:

systemctl restart atop.service

lfjeff
  • 121
  • 3
  • 1
    this does not seem to work on Raspbian 9 ` sudo systemctl restart atop.service sudo systemctl status atop.service Main PID: 1518 (atop) CGroup: /system.slice/atop.service └─1518 /usr/bin/atop -a -R -w /var/log/atop/atop_20190405 600 ` so it's still running at 10 min interval. Also /etc/default/atop file has comment "# this file is no longer used and will be removed in a future release" – Aleksandr Levchuk Apr 05 '19 at 15:35
1

Correction: the default sampling interval for atop is 10 seconds; atop writes compressed binary data to /var/log/atop/atop_YYYYMMDD every 10 minutes.

Sampling intervals and log file locations can be set from the command line. To set the sample interval to one minute:

atop 60

Set compressed raw format log to foo.log:

atop -w foo.log
agc
  • 7,045
  • 3
  • 23
  • 53
  • but how to change the log path to `/var/log/atop/foo.log` ? – Raptor Apr 13 '16 at 06:18
  • 1
    @Raptor, do we need to? Find out with: `ps -A atop && lsof -p $(pidof atop) | grep log` – agc Apr 13 '16 at 07:12
  • Although this is the accepted answer I believe it misses the point of the question which is about *configuring* atop with non-default settings and not *running* atop with non default settings. – ndemou May 16 '19 at 07:16
  • @ndemou, Perhaps it is about configuring and not running `atop`, and [*Rifaideen*'s answer](https://unix.stackexchange.com/a/397902/165517) is more correct. If that is so, then the question should be revised, so that its wording makes the *OP*'s true intent obvious. *OTOH*, the *OP* did accept this answer, so I dunno. "Plan B" would be to just ask another question about how to change `atop` log file location & default duration. – agc May 16 '19 at 12:07
0

you need to change the values as your need on the file /etc/sysconfig/atop

mainly

LOGOPTS=""
LOGINTERVAL=600
LOGGENERATIONS=28
LOGPATH=/var/log/atop
  • Welcome to U&L. Please note, you're answering to a 7y old question with an [accepted answer](https://unix.stackexchange.com/help/accepted-answer). While providing new insight to old questions is perfectly fine, at this point the answer really needs to provide something essentially new. As far as I can see you're just re-hashing the 4 previous answers, so what exactly is the new thing you're bringing to the table? – Peregrino69 Mar 21 '23 at 13:42
  • Without digging too deep into the details, I notice that this new answer refer to **LOG**INTERVAL, while all older answers seem to be mentioning INTERVAL. It appears the variable was switched in commit [9628791](https://github.com/Atoptool/atop/commit/9628791). Maybe someone with deeper interest in atop could dig into that and clarify whether the rename is crucial or not? – sampi Mar 24 '23 at 15:15
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 24 '23 at 15:18