我不希望我的 systemd 服务在启动时运行并且我无法停止它。
我创建了自己的脚本、服务和计时器文件,用于自动备份到 Backblaze。我找到了 3 或 4 个关于此事的论坛帖子,但这些解决方案都没有帮助我。
如果我删除[Install]
.service 中的部分,状态将更改为static
. 它仍然在启动时运行。
这是我的 .service 文件:
ryley@pop-os:~$ cat /etc/systemd/system/b2backup.service
[Unit]
Description=Backblaze Backup Script
[Service]
User=ryley
Group=ryley
Type=simple
ExecStart=/home/ryley/b2backup.sh --full --to-external
Restart=on-failure
[Install]
WantedBy=multi-user.target
这是我的计时器文件:
ryley@pop-os:~$ cat /etc/systemd/system/b2backup.timer
[Unit]
Description=timer for Backblaze upload script
Requires=b2backup.service
[Timer]
Unit=b2backup.service
OnCalendar=Sun 03:00:00
[Install]
WantedBy=multi-user.target
这是状态:
ryley@pop-os:~$ systemctl status b2backup.service
● b2backup.service - Backblaze Backup Script
Loaded: loaded (/etc/systemd/system/b2backup.service; disabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2020-11-23 20:58:30 PST; 12h ago
TriggeredBy: ● b2backup.timer
Process: 944 ExecStart=/home/ryley/b2backup.sh --full --to-external (code=exited, status>
Main PID: 944 (code=exited, status=0/SUCCESS)
这表明该服务已禁用:
ryley@pop-os:~$ systemctl list-unit-files --state=disabled
UNIT FILE STATE VENDOR PRESET
proc-sys-fs-binfmt_misc.mount disabled enabled
acpid.service disabled enabled
b2backup.service disabled enabled
任何帮助是极大的赞赏。我已经在这几个小时了。