gpt4 book ai didi

linux - 重新启动时运行 shell 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 04:50:04 25 4
gpt4 key购买 nike

尝试了两种方法,但似乎都不起作用:

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来跟进。

目前不确定出了什么问题 - 感谢任何帮助。

最佳答案

你启用了cron吗?

您可以启用并启动它

sudo systemctl enable cron.service   

关于linux - 重新启动时运行 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59828502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com