tmp 目录文件无法执行, 报 Permission denied

今天在执行 aysnc-profiler 的时候, 遇到无法执行的问题: 为了方便文件清除, 把解压后的文件放到了 /tmp 目录, 然后把 owner 和 权限都加好, 之后切换java 进程的用户去执行, 报 Permission denied.

mkdir /tmp/profiler
tar -C /tmp/profiler -xvf async-profiler-1.7.1-linux-x64.tar.gz
sudo chmod -R 755 /tmp/profiler/*
sudo chown -R appuser /tmp/profiler
sudo su appuser
/tmp/profiler/profile.sh -d 60 -o tree -e cpu -f profile0717.log.html 
/tmp/profile/profiler.sh: Permission denied

如果使用 bash 去执行, 则报:

bash /tmp/profiler/profile.sh -d 60 -o tree -e cpu -f profile0717.log.html 
/tmp/profile/profiler.sh: line 67: /tmp/profile/build/jattach: Permission denied

既然文件 owner 和 读和执行权限都加好了, 为什么还报错呢?
原来在 /tmp 目录的挂载方式:

appsuer@test-host:/home/appuser$ mount | grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec)

它设置了 noexec 属性. 所以问题就知道出在那里了, 既然这样, 换个目录就解决了.

标签: none

添加新评论