修改每個實(shí)例的用戶數(shù)據(jù)
實(shí)例 => 操作?=>?實(shí)例設(shè)置?=>?編輯用戶數(shù)據(jù)
Content-Type: multipart/mixed; boundary="http://"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
/bin/echo "Hello World" >> /tmp/testfile.txt
--//--
- [scripts-user, always]:重啟也執(zhí)行一遍這個腳本
/bin/echo "Hello World" >> /tmp/testfile.txt :此部分可以替換成你自己的腳本代碼
注意:這個腳本任務(wù)是使用的root用戶執(zhí)行的,所以需要注意shell代碼里 ~ 的路徑指向
參考:
在 EC2 實(shí)例初始啟動之后運(yùn)行用戶數(shù)據(jù) | AWS re:Post
Run commands on your Linux instance at launch - Amazon Elastic Compute Cloud文章來源:http://www.zghlxwxcb.cn/news/detail-510181.html
在亞馬遜 AWS 上重新啟動 EC2 實(shí)例后,讀取腳本執(zhí)行自動配置的問題。_aws userdata重啟實(shí)例會執(zhí)行嗎_茶兒啤酒的博客-CSDN博客文章來源地址http://www.zghlxwxcb.cn/news/detail-510181.html
到了這里,關(guān)于AWS實(shí)例啟動時自動執(zhí)行腳本的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!