我们使用下面的脚本作为 EC2 实例的用户数据。我不明白 -ex
选项的用途是什么?
#!/bin/bash -ex
yum update -y
yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"
service httpd start
chkconfig httpd on
最佳答案
根据Add tack e x on your bash shebang | #!/bin/bash -ex
Bash scripts can use various options on the shebang (#!/bin/bash). A more common one is: ‘#!/bin/bash -ex’.
-e
Exit immediately if a command exits with a non-zero status.
-x
Print commands and their arguments as they are executed.In short, adding
-ex
to your#!/bin/bash
will give verbose output and also will abort your script immediately if part of the script fails.
关于linux - bash 中使用的 -ex 选项是什么 | #!/bin/bash -ex 意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38342992/