RedHat-重新启动后启动命令

问题描述 投票:0回答:1

操作系统:Red Hat Enterprise Linux Server 7.7(Maipo)CPE操作系统名称:cpe:/ o:redhat:enterprise_linux:7.7:GA:server内核:Linux 3.10.0-1062.9.1.el7.x86_64架构:x86-64

大家好,

每次重新启动VM时,我都需要执行命令。例如:/ opt / local / bin / application.sh全部启动该脚本必须由应用程序用户非root用户

执行。

我试图将此命令放在另一个Shell脚本中,并按照RHEL7的建议创建服务。(https://www.tecmint.com/create-new-service-units-in-systemd/


[单元]说明=说明之后= network.target[服务]用户= my_app_userExecStart = /opt/local/bin/start_the_app.sh

[安装]WantedBy = multi-user.target


事实是这不是一项服务,不应该一直运行,而只是一个Shell脚本,应在重启后仅执行一次。

如何在RHEL7中完成?

谢谢。

linux redhat systemd rhel7
1个回答
0
投票

我相信您正在@reboot中寻找crontab选项,因为您希望在重新启动后仅运行一次脚本,因此可以尝试以下操作:

@reboot /complete_path_of_your_script

使用crontab -e编辑cron条目,然后输入上述条目,请确保此处提供了完整的脚本路径。

© www.soinside.com 2019 - 2024. All rights reserved.