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

时间:2014-04-03 23:59:55

标签: linux amazon-ec2

我做了这个

$ 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新手。 感谢

1 个答案:

答案 0 :(得分:1)

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

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

$ chown root.root /home/mysh.sh

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

$ chmod u+x /home/mysh.sh
相关问题