我试图在桌面系统每晚关闭之前运行用户服务来备份我的文档。
# Needs to be placed in ~/.config/systemd/user/
[Unit]
Description=Backup with restic before shutdown
Before=poweroff.target halt.target
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/restic backup --verbose --one-file-system --tag systemd.shutdown $BACKUP_EXCLUDES $BACKUP_PATHS
ExecStartPost=/usr/bin/restic forget --verbose --tag systemd.shutdown --group-by paths,tags --keep-daily $RETENTION_DAYS --keep-weekly $RETENTION_WEEKS --keep-monthly $RETENTION_MONTHS --keep-yearly $RETENTION_YEARS
EnvironmentFile=%h/.config/restic-backup.conf
RemainAfterExit=yes
[Install]
WantedBy=poweroff.target halt.target
如果我手动启动它,它就会运行: systemctl --user start restic-backup.service
似乎启用了罚款:systemctl --user enable restic-backup.service
返回:
Created symlink /home/lance/.config/systemd/user/poweroff.target.wants/restic-backup.service → /home/lance/.config/systemd/user/restic-backup.service.
Created symlink /home/lance/.config/systemd/user/halt.target.wants/restic-backup.service → /home/lance/.config/systemd/user/restic-backup.service.
...但是当我进入桌面菜单并关机时,脚本没有运行,计算机只是关机。
有人看到我遗漏了什么吗?