尝试了两种方法,似乎都没有用:
crontab -e
:
@reboot sleep 60;/home/linuxbox/script.sh
并在/etc/systemd/system/script.service
中创建了服务:
[Unit]
Description=a generic service to run on reboot
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=/bin/bash /home/linuxbox/script.sh
Type=simple
User=linuxbox
Group=linuxbox
WorkingDirectory=/home/linuxbox
我跟着systemctl daemon-reload
。
不确定目前出了什么问题,不胜感激。
您启用了crond吗?
您可以启用并以它开头
sudo systemctl enable crond.service
ExecStart
命令不应该
/bin/bash /home/linuxbox/script.sh
但应该是
/bin/bash -c "/home/linuxbox/script.sh"
。