在/etc/systemd/system
目录中我有:
rsnapshot-backup.service
文件,内容如下:
[Unit]
Description=rsnapshot backup automation [cron like]
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/bin/notify-send "Rsnapshot Hourly Backup In Progress"
和rsnapshot-backup.timer
文件,内容如下:
[Unit]
Description=hourly rsnapshot backup
[Timer]
OnCalendar=*-*-* *:43:00
Persistent=true
[Install]
WantedBy=timers.target
但我没看到notify-send
被触发?可能出了什么问题?
systemctl list-timers
给出:
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sat 2014-08-16 09:43:00 CEST 2min 37s left Sat 2014-08-16 09:31:18 CEST 9min ago rsnapshot-backup.timer rsnapshot-backup.service
systemctl status rsnapshot-backup.service
给出:
● rsnapshot-backup.service - rsnapshot backup automation [cron like]
Loaded: loaded (/etc/systemd/system/rsnapshot-backup.service; static)
Active: inactive (dead) since Sat 2014-08-16 09:31:21 CEST; 11min ago
Process: 228 ExecStart=/usr/bin/notify-send Rsnapshot Hourly Backup In Progress (code=exited, status=0/SUCCESS)
Main PID: 228 (code=exited, status=0/SUCCESS)
systemctl status rsnapshot-backup.timer
给出:
● rsnapshot-backup.timer - hourly rsnapshot backup
Loaded: loaded (/etc/systemd/system/rsnapshot-backup.timer; enabled)
Active: active (waiting) since Sat 2014-08-16 09:31:16 CEST; 12min ago
编辑
这样做journalctl -u rsnapshot-backup
,我可以确认服务已成功启动,但是没有显示任何内容(通知发送)。
-- Reboot --
Aug 16 09:43:14 ----------------- systemd[1]: Starting rsnapshot backup automation [cron like]...
Aug 16 09:43:14 ----------------- systemd[1]: Started rsnapshot backup automation [cron like].
Aug 16 10:00:06 ----------------- systemd[1]: Starting rsnapshot backup automation [cron like]...
Aug 16 10:00:07 ----------------- systemd[1]: Started rsnapshot backup automation [cron like].
Aug 16 10:19:04 ----------------- systemd[1]: Starting rsnapshot backup automation [cron like]...
Aug 16 10:19:04 ----------------- systemd[1]: Started rsnapshot backup automation [cron like].