我正在尝试编写带有计时器的服务。但它没有被执行:
示例@主机/etc/systemd/system/mbsync.service:
[Unit]
Description=Mailbox synchronisation service for user example
[Service]
Type=oneshot
ExecStart=/usr/bin/mbsync -aV
User=example
StandardOutput=syslog
StandardError=syslog
示例@主机/etc/systemd/system/mbsync.timer:
[Unit]
Description=Mailbox synchronisation timer
[Timer]
OnBootSec=10s
OnCalendar=*:00/2
[Install]
WantedBy=default.target
我是这样启动服务的:
systemctl daemon-reload
systemctl enable mbsync.timer
systemctl start mbsync.timer
但我只得到:
systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Mon 2015-11-30 11:50:00 CET 10s ago Mon 2015-11-30 11:50:07 CET 2s ago mbsync.timer mbsync.service
答案1
你的计时器是已执行,但可能不会达到您的预期。您应该检查日志systemctl status -l mbsync.service
并相应地调整您的日志.mbsyncrc
。
我发现这些资源很有帮助:
- https://wiki.archlinux.org/index.php/Isync#Automatic_synchronization
- https://www.bostonenginerd.com/posts/notmuch-of-a-mail-setup-part-1-mbsync-msmtp-and-systemd/
尤其是第二个,与用户单元文件,使用PassCmd "gpg ..."
.