0

On my Ubuntu 21.10 Ubuntu desktop, which is sometimes on at midnight (if I happen to be awake and using it), a nightly event takes place where there is a lot of disk activity -- the red light for the HDD is blinking repeatedly, even though I'm not doing anything. I don't know what it is, but it does cause the system to slow down.

I know it isn't a user-level or a root-level cronjob. I've checked that. So, I guess it's something that has been turned on by default. I suppose I also have a slight concern that it's something done by an outside party, but I guess that's unlikely since midnight every night is a bit too predictable.

I have set up a backup program, but that program doesn't run at midnight. It's possible it's just rotating log files or something. Whatever it is, I just want to know what it is (and maybe move it to another time).

Anyway, what can I do to figure out what's causing this? I have looked at the output of top, but nothing looks out of place. Besides the user and root's crontab, is there anything else I should check?

Any suggestions would be appreciated!

Ray
  • 1,987
  • 17
  • 27
  • 1
    Did you try running a resource monitor (like `htop`) during this time, and see which process consumes most CPU? – Artur Meinild Mar 06 '22 at 17:59
  • 1
    What do your logs for that time say? – user535733 Mar 06 '22 at 18:35
  • 1
    You're experiencing some "cron" jobs, or scheduled timer jobs that do some housekeeping. Check with `systemctl list-timers` (maybe also `crontab -l`) the list of timers. They will also show you when they start again – kanehekili Mar 06 '22 at 18:27
  • @kanehekili Thank you! I didn't know about `systemctl list-timers`. (It wasn't anything I set in `crontab`, though.) Combined with the answer below, I was able to find the culprit to be `mlocate`. Thank you! – Ray Mar 08 '22 at 09:42

1 Answers1

1

Look at the logs:

# Use the power of the date command to produce journalctl-friendly date format
alias tsjou='date '\''+%y-%m-%d %H:%M:%S'\'''

Examples:

walt@bat:~(0)$ tsjou
22-03-06 14:02:25
walt@bat:~(0)$ tsjou --date="23:45 yesterday"
22-03-05 23:45:00

To see the system logs around midnight:

sudo journalctl --since="$(tsjou --date="23:45 yesterday")" \
                --until="$(tsjou --date="00:15")"

Read man date journalctl. I have more journalctl hints at https://askubuntu.com/users/25618/waltinator?tab=profile You'll have to click the "Read more" button - I'm verbose.

waltinator
  • 35,099
  • 19
  • 57
  • 93
  • Thank you for this! I know about `journalctl`, but not well enough to make it useful for me. Combining your suggestion with `systemctl list-timers` in the comments above, I found out that rotating logs, man-db regeneration, and `mlocate` were running simultaneously. The first two finish in 30 seconds. `mlocate` runs for about 20 minutes but says it consumed 1 min of CPU time. I guess it has a lot of disk I/O...I will have to do something about it. I did find [this](https://askubuntu.com/questions/268130/can-i-disable-updatedb-mlocate) just now. Thank you for reply and the hints! – Ray Mar 08 '22 at 09:39