当您使用
command-runner.jar
时,您可以在步骤的参数列表中指定命令、选项和值。
以下 AWS CLI 示例向正在调用的
command-runner.jar
正在运行的集群提交一个步骤。
Args
列表中的指定命令将
my-script.sh
从 Amazon S3 调用的脚本下载到 hadoop 用户主目录中。然后,该命令修改脚本的权限并运行
my-script.sh
。
使用时 AWS CLI,
Args
列表中的项目应以逗号分隔,列表元素之间不应有空格。例如,使用
Args=[example-command,example-option,"example option value"]
而不是
Args=[example-command, example-option, "example option
value"]
。
aws emr add-steps \
--cluster-id j-2AXXXXXXGAPLF \
--steps Type=CUSTOM_JAR,Name="Download a script from S3, change its permissions, and run it",ActionOnFailure=CONTINUE,Jar=command-runner.jar,Args=[bash,-c,"aws s3 cp s3://amzn-s3-demo-bucket/my-script.sh /home/hadoop; chmod u+x /home/hadoop/my-script.sh; cd /home/hadoop; ./my-script.sh"]