我正在尝试修改一个systemd服务脚本,以便在重新启动时执行任务。下面是脚本,当我运行systemctl启动script.service时,它可以工作,但是当我重新启动系统时,它就不能工作了。
[Unit]
Description=put cloudify in maintenance mode on shutdown
DefaultDependencies=no
Before=reboot.target
[Service]
Type=oneshot
ExecStart=/bin/cfy maintenance-mode activate
TimeoutStartSec=0
[Install]
WantedBy=reboot.target我已经执行了: systemctl守护进程重新加载和systemctl启用script.service。
该命令将使应用程序进入维护模式。
vm上为此需要的所有服务也都已启用。
我不知道我做错了什么,如果有任何帮助,我们将不胜感激。
发布于 2022-05-18 02:30:10
在系统重新启动之前运行该服务。您需要将此依赖项添加到服务文件中。
[Unit]
Description=put cloudify in maintenance mode on shutdown
DefaultDependencies=no
After=final.target
[Service]
Type=oneshot
ExecStart=/bin/cfy maintenance-mode activate
TimeoutStartSec=0
[Install]
WantedBy=final.targethttps://stackoverflow.com/questions/71945755
复制相似问题