jes*_*516 6 systemd systemd-timer
如何让下面的定时器自动启动?现在计时器只有在我这样做时才起作用systemctl start while-test.timer
。否则,即使我启用了计时器,它也不会自动启动。即使在执行systemctl daemon-reload
或重新启动之后。
while-test .service
-------------------
[Unit]
Description=While loop test script
[Service]
Type=simple
ExecStart=/home/user/bash/while-test.sh
[Install]
WantedBy=default.target
Run Code Online (Sandbox Code Playgroud)
和
while-test .timer
----------------
[Unit]
Description=While loop test script timer
[Timer]
OnCalendar=Mon *-*-* 10:52:00
Unit=while-test.service
[Install]
WantedBy=default.service
Run Code Online (Sandbox Code Playgroud)
小智 3
systemctl enable while-test.service
systemctl enable while-test.timer
Run Code Online (Sandbox Code Playgroud)
您可能需要使用 sudo 运行它们。这将在启动时启用服务和计时器。验证它是否已启用:
systemctl list-timers
Run Code Online (Sandbox Code Playgroud)
这将显示状态信息,例如下次运行时间、上次运行时间、上次运行以及它激活的服务。
归档时间: |
|
查看次数: |
5722 次 |
最近记录: |