amazon-ec2 - ubuntu ec2 实例上的 cloud-init 每次启动脚本

标签 amazon-ec2 ubuntu-11.10 cloud-init

我正在尝试在 ubuntu 11.10 ec2 实例上使用 cloud-init 启动脚本。

我将脚本 script.sh 放在文件夹 /var/lib/cloud/scripts/per-boot 中。
script.sh的内容很简单:

#/!/bin/sh 
echo "test"

重新启动后,出现以下错误:

run-parts: failed to exec /var/lib/cloud/scripts/per-boot/script.sh: Exec format error
run-parts: /var/lib/cloud/scripts/per-boot/script.sh exited with return code 1
2012-04-14 19:10:52,642 - cc_scripts_per_boot.py[WARNING]: failed to run-parts in /var/lib/cloud/scripts/per-boot
2012-04-14 19:10:52,648 - __init__.py[WARNING]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 108, in run_cc_modules
    cc.handle(name, run_args, freq=freq)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 72, in handle
    [ name, self.cfg, self.cloud, cloudinit.log, args ])
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 309, in sem_and_run
    func(*args)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_scripts_per_boot.py", line 27, in handle
    util.runparts(runparts_path)
  File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 140, in runparts
    raise subprocess.CalledProcessError(sp.returncode,cmd)
CalledProcessError: Command '['run-parts', '--regex', '.*', '/var/lib/cloud/scripts/per-boot']' returned non-zero exit status 1

2012-04-14 19:10:52,648 - __init__.py[ERROR]: config handling of scripts-per-boot, None, [] failed

cloud-init boot finished at Sat, 14 Apr 2012 19:10:52 +0000. Up 3.70 seconds
2012-04-14 19:10:52,672 - cloud-init-cfg[ERROR]: errors running cloud_config [final]: ['scripts-per-boot']
errors running cloud_config [final]: ['scripts-per-boot']

有什么解决办法吗?

最佳答案

我相信您的问题与 #/!/bin/sh 不是有效的输入类型有关。需要去掉#后面的/。

#!/bin/sh 
echo "test"

如果您在此之后仍然遇到问题,请告诉我。

关于amazon-ec2 - ubuntu ec2 实例上的 cloud-init 每次启动脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10156692/

相关文章:

hadoop - 更改EC2上hadoop集群的所有者

mysql - 在 ec2 实例上访问 phpMyAdmin 时出现 403 错误

amazon-ec2 - EC2上的Spark无法利用所有可用内核

performance - AWS 上的 Web 应用程序性能监控

linux - Azure虚拟机上使用cloud-init挂载数据盘失败

c# - Mono-LibreOffice System.TypeLoadException

Java 不能在 ubuntu 11.10 上使用 netbeans IDE 7

linux - 在 Ubuntu 11.10 中显示经典 View

linux - 使用 cloud-init 用户数据

javascript - 当从 Grunt 传递到 CasperJS 时,字符串会被破坏