在任何其他linux发行版上,我都可以创建一个带有shebang的文件,并运行shell脚本,如下所示:
$ chmod +x test.sh
$ ./test.sh Johnny
hello Johnny但是在Google平台容器优化操作系统上,我得到了-bash: ./test.sh: Permission denied
如果我以sh (例如sh test.sh Johnny )作为前缀,它就会起作用。我怎么才能让这个正常工作?
$ cat test.sh
#!/usr/bin/env sh
echo "Hello $@"
matt@rancher-4mmm /tmp/matt $ chmod +x test.sh
matt@rancher-4mmm /tmp/matt $ sh ./test.sh matt
Hello matt
matt@rancher-4mmm /tmp/matt $ ./test.sh matt
-bash: ./test.sh: Permission denied
matt@rancher-4mmm /tmp/matt $ ls -la
total 4
drwxr-xr-x 2 matt matt 60 Feb 28 20:00 .
drwxrwxrwt 14 root root 280 Feb 28 19:59 ..
-rwxr-xr-x 1 matt matt 35 Feb 28 20:00 test.sh发布于 2018-05-10 18:33:24
COS节点上的大多数文件系统都使用"noexec“标志挂载,因此不能从它们执行二进制文件。
一些解决办法:
发布于 2018-03-01 01:20:12
发布于 2019-06-16 06:22:46
如果您想一次性运行二进制文件,并且不想处理另一个PD,也可以安装tmpfs设备并从那里运行它。
sudo mkdir /mnt/disks/scratch
sudo mount -t tmpfs tmpfs /mnt/disks/scratch/https://stackoverflow.com/questions/49037720
复制相似问题