我有我的amazon实例,我需要添加一个shell脚本到它的rc.local文件,以便在我启动我的实例时执行shell脚本。 如何在rc.local文件中设置我的shell脚本的权限?
如果我执行如下所示,我的脚本不会在启动时执行
chmod u + x /home/mylin/exmpl.sh
./exmpl.sh&
您可以使用crontab在启动时执行命令:
http://www.cyberciti.biz/faq/linux-execute-cron-job-after-system-reboot/
你必须“chmod + x”你的脚本,然后使用完整的path。
chmod +x /home/mylin/exmpl.sh
然后在你的crontab中:
@reboot /home/mylin/exmpl.sh
或者在你的rc.local文件中:
/home/mylin/exmpl.sh
确保在/etc/rc.local中使用了脚本的完整path。
如果您的脚本位于/home/mylin/exampl.sh,则rc.local中的行应为:
/home/mylin/exampl.sh &