Skip to content
Advertisement

Execute screen command returning `Cannot make directory ‘/var/run/screen’: File exists`

I’ve no idea what is happening. I can run any other shell command through the exec() command and it works fine. It’s clearly something to do with permissions somewhere, but I’m unsure what. I’ve tried this on many different servers and some of them work fine and some don’t. All were running CentOS. Safe mode is always off.

This is the code I’m trying to get to work:

JavaScript

All thats returned is this:

JavaScript

Can anyone please shed some light on this at all?

Advertisement

Answer

Update: This was caused by SELinux.

Turns out it was some weird file system/user permissions error. After running ls -al /var/run through the exec() command in PHP, it returned this:

JavaScript

I fixed it by deleting the directory and making the /var/run permissions 0777. This meant that the web server user could create the directory and use it as expected.

JavaScript

I still don’t know why this has happened, nor why there are question marks all over the place in the ls command. If anyone sees this and knows, please leave a comment or answer explaining why. It will be a big help, since I know have more errors.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement