gpt4 book ai didi

linux - 如何在 AWS EC2 重启/启动时运行 sh 文件

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:58:45 26 4
gpt4 key购买 nike

这是我做的

$ vi/etc/rc.local

并向该文件添加了 1 行。现在这个文件看起来像这样:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/home/mysh.sh

我重新启动 EC2。但是mysh.sh好像没有运行。我承认我是 Linux 新手。谢谢

最佳答案

只需将解决方案作为答案发布即可:

/home/mysh.sh 的所有权更改为 root:

$ chown root.root /home/mysh.sh

此外,确保它具有可执行权限:

$ chmod u+x /home/mysh.sh

关于linux - 如何在 AWS EC2 重启/启动时运行 sh 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22851160/

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