Snapper每小时生成重复快照问题咨询:同一PID触发两次快照
Alright, let's tackle this weird Snapper duplicate snapshot issue you're seeing. For two years it's worked flawlessly, now suddenly every hour you get two snapshots—one on the dot, one a minute later, both from the same PID. No errors in the logs either? That's definitely odd, but let's break down the most likely causes and how to debug them:
1. Check for Conflicting Systemd Timer/Service Configs
Since the same PID is triggering both snapshots, we can rule out multiple independent processes running the task. But systemd timers sometimes have subtle configuration issues that cause duplicate triggers:
- First, list all Snapper-related timers to see what's active:
systemctl list-timers | grep snapper - Inspect the timer's configuration file (usually either
/usr/lib/systemd/system/snapper-timeline.timeror a custom one in/etc/systemd/system/):
Pay close attention to thecat /usr/lib/systemd/system/snapper-timeline.timerOnCalendardirective—make sure it's only set to*-*-* *:00:00(hourly on the minute) and doesn't have an extra rule for*:01:00, or wildcards that might accidentally match both times. - Also check if there's a duplicate timer file in
/etc/systemd/system/that's overriding or supplementing the default one.
2. Audit Snapper's Timeline Configuration
Snapper's own timeline settings might have a misconfiguration that's causing the same task to run twice in quick succession:
- Open your Snapper config file (located in
/etc/snapper/configs/, typically named after your target likeroot):
Look for parameters likecat /etc/snapper/configs/rootTIMELINE_CREATE,TIMELINE_INTERVAL, andTIMELINE_MIN_AGE. EnsureTIMELINE_INTERVALis set to60(minutes) and there's no conflicting logic that would trigger an extra snapshot immediately after the first. - If you've made recent changes to this config, reverting to a known-good version (or the default) could help isolate the issue.
3. Dig Into Systemd's Detailed Logs
Even if Snapper's own logs look clean, systemd might have clues about why the service is being triggered twice:
- Pull the recent logs for the Snapper timeline service:
Look for two start events within a minute of each other—note the trigger reason (e.g.,journalctl -u snapper-timeline.service --since "3 hours ago"timer elapsesvs. some other event). This can tell you if the timer is firing twice, or if something else is kicking off the service. - You can also check the timer's current status to see its scheduled triggers:
systemctl status snapper-timeline.timer
4. Rule Out Cron Overlaps
It's easy to forget about old cron jobs that might be conflicting with the systemd timer:
- Check the system crontab:
cat /etc/crontab - Check root's user crontab:
Look for any entries that runcrontab -l -u rootsnapper createor call a script that does—if there's one set for0 * * * *and another for1 * * * *, that's your culprit. Even if the cron job ends up reusing the same Snapper process (unlikely, but possible), it could explain the duplicate snapshots.
5. Test a Manual Trigger
To narrow down whether the issue is with the trigger mechanism or Snapper itself:
- Stop the systemd timer temporarily:
systemctl stop snapper-timeline.timer - Manually run the timeline service once:
systemctl start snapper-timeline.service - Check the snapshot list:
If this manual run creates two snapshots, the problem is in Snapper's internal logic—try updating to the latest version or checking for known bugs. If it only creates one, the issue is definitely with the timer/cron trigger setup.snapper list
内容的提问来源于stack exchange,提问作者MountainX

