# apache and mod_php not able to exec uptime



## wonslung (Jun 7, 2009)

i've got a php page that shows some basic system stats, one of them being system load.  I use uptime for it....heres what's weird.

It's not working.

I see this in my apache error log 
	
	



```
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
uptime: /var/run/utmp: Permission denied
```

but i've checked both the permissions of uptime AND /var/run/utmp and they are fine...

even more odd, the same system running the same thing in a jail, it works....any idea what's going on and how to fix this?


----------



## rhyous (Jun 8, 2009)

So if it is php code, do you want to post it.

If it probably because what you are doing cannot be done as the user that is running the php script on the server.

Make the user (such as www) temporarily able to login for testing purposes. Log in as that user and see if you can read /var/run/utmp.  You probably can't.  Edit the permissions until you can.  Try to give the least permissions possible, but for temporary testing chmod 777 /var/run/utmp might not be a bad thing to test.


----------



## wonslung (Jun 8, 2009)

The permissions are right, the very first thing i tried was changing it to 777 to see if it made a difference...it didn't
644 should work though.
i've tried all the permissions 
that was the FIRST thing i've done.


```
<?php
echo exec("/usr/bin/uptime");
?>
```
should work.
it doesn't.
permissions are correct.

This works inside a jail on the same server but not in the host os.


----------



## anomie (Jun 11, 2009)

From the _host_ (not the jail), does *uptime* work from the command line? 

Is php able to run other shell commands successfully?


----------

