systemctl失败,未知部分'Timer'

时间:2018-05-15 15:29:16

标签: rhel systemd systemctl

我有一个执行vertica备份到s3的systemctl作业,我想添加一个每天凌晨3点运行的计时器。我尝试使用计时器部分创建一个覆盖文件但是当我进行守护进程重新加载时,我收到错误“未知部分计时器”,我无法找到问题。

/etc/systemd/system/vertica-backup.service.d/Override.conf

[Timer]
OnCalendar=*-*-* 03:00:00
Unit=vertica-backup.service

/etc/systemd/system/vertica-backup.service:

[Unit]
Description = Vertica Backup Service
After = network.target

[Service]
User= dbadmin
ExecStart= /usr/local/bin/vertica-backup.sh

错误

May 15 15:19:47 ip-10-150-4-42.ec2.internal systemd[1]: [/etc/systemd/system/vertica-backup.service.d/override.conf:1] Unknown section 'Timer'. Ignoring.
May 15 15:19:50 ip-10-150-4-42.ec2.internal systemd[1]: [/etc/systemd/system/vertica-backup.service.d/override.conf:1] Unknown section 'Timer'. Ignoring.

2 个答案:

答案 0 :(得分:3)

[Timer]部分不会进入服务文件,而是放在他们自己的.timer文件中。创建/etc/systemd/system/vertica-backup.timer并将[Timer]部分放在那里。

请参阅man systemd.timer以供参考。

答案 1 :(得分:0)

创建计时器文件/etc/systemd/system/vertica-backup.timer

[Timer]
OnCalendar=*-*-* 03:00:00
Unit=vertica-backup.service

验证

sudo systemd-analyze verify /etc/systemd/system/vertica-backup.timer

启动计时器

sudo systemctl start vertica-backup.timer

# check it
systemctl list-timers --all