Linux 如何在AWS EC2重新启动/启动时运行sh文件

Linux 如何在AWS EC2重新启动/启动时运行sh文件,linux,amazon-ec2,Linux,Amazon Ec2,是我干的 $vi/etc/rc.本地 并在此文件中添加了一行。现在,此文件如下所示: #!/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/

是我干的

$vi/etc/rc.本地

并在此文件中添加了一行。现在,此文件如下所示:

#!/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

是否创建了/var/lock/subsys/local?并且,/home/mysh.sh是否标记为可执行文件?是的,有一个/var/lock/subsys/local,它是空的。我可以这样运行mysh.sh:$sh/home/mysh.sh您可以这样运行mysh.sh:$/home/mysh.sh-?/var/lock/subsyslocal上最后修改的时间是否与引导时间相同?/var/lock/subsyslocal上最后修改的时间是否与引导时间相同。让我在文件中尝试$sh/home/mysh.sh并重新启动。谢谢。现在可以了。脚本是在root用户下运行的,而不是我所认为的ec2用户。