Ama*_*ava 1 linux bash shell amazon-ec2 amazon-web-services
我的本地机器上有一个脚本,可以帮助我连接到我的ec2。但是,它不会运行指定的脚本文件。
awsconnect.sh:
ssh -i ".pemfile" ubuntu@"ec2-instance"
./data.sh
Run Code Online (Sandbox Code Playgroud)
data.sh是我在aws-ec2上的文件。
data.sh:
mkdir -p dumps/$(date +"%Y%m%d");
mysqldump -h localhost -port=3306 -u root -proot abc | gzip > dumps/$(date +"%Y%m%d")/abc.sql.gz;
logout
Run Code Online (Sandbox Code Playgroud)
My data.sh file is running fine if i run it from aws-ec2 command line.
But, it is not running from my script file.
What is the problem?
Are you able to ssh into the machine fine? If so, then you just need to make sure that ownership and permissions are ok for the script. Then you can:
ssh -i key.pem ubuntu@ec2-instance "bash /path/to/your/script/data.sh"
Run Code Online (Sandbox Code Playgroud)
However, if things in your script need root access, then you would need permissions.
Edit: As @error2007s mentioned, I forgot to specify the identity file in my command. I've edited the command, so put that in awsconnect.sh and it should work fine.
| 归档时间: |
|
| 查看次数: |
4517 次 |
| 最近记录: |