diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix index 77e4fc395981..082cf92ff4ef 100644 --- a/nixos/modules/services/logging/logrotate.nix +++ b/nixos/modules/services/logging/logrotate.nix @@ -167,7 +167,6 @@ in systemd.services.logrotate = { description = "Logrotate Service"; - wantedBy = [ "multi-user.target" ]; startAt = "hourly"; serviceConfig = { diff --git a/nixos/tests/logrotate.nix b/nixos/tests/logrotate.nix index 0f6b59f071d4..0dee5d4502d9 100644 --- a/nixos/tests/logrotate.nix +++ b/nixos/tests/logrotate.nix @@ -15,19 +15,20 @@ import ./make-test-python.nix ({ pkgs, ...} : rec { with subtest("whether logrotate works"): machine.succeed( # we must rotate once first to create logrotate stamp - "systemctl start --wait logrotate.service", + "systemctl start logrotate.service") + # we need to wait for console text once here to + # clear console buffer up to this point for next wait + machine.wait_for_console_text('logrotate.service: Deactivated successfully') + machine.succeed( # wtmp is present in default config. "rm -f /var/log/wtmp*", "echo test > /var/log/wtmp", - # move into the future and rotate - "date -s 'now + 1 month + 1 day'", - # systemd will run logrotate from logrotate.timer automatically - # on date change, but if we want to wait for it to terminate - # it's easier to run again... - "systemctl start --wait logrotate.service", - + # move into the future and check rotation. + "date -s 'now + 1 month + 1 day'") + machine.wait_for_console_text('logrotate.service: Deactivated successfully') + machine.succeed( # check rotate worked "[ -e /var/log/wtmp.1 ]", )