Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to check postfix active queue. I php script I use

$active = shell_exec('/bin/ls -1 /var/spool/postfix/active | /usr/bin/wc -l');

But in log I see

/bin/ls: cannot open directory /var/spool/postfix/active: Permission denied

What group I need to add php or postfix to avoid this error ?

share|improve this question
    
Which Linux distribution are you using? –  Gazzonyx Apr 8 '13 at 6:00

1 Answer 1

up vote 1 down vote accepted

On Debian, PHP is run by default on the www-data:www-data user. So /var/spool/postfix/active is not accessible as it is owned by postfix.

So you must go root before doing that.

It is maybe easier to run a mailq | egrep ^\*|wc -l to have the same result without the problem because mailq is a link to sendmail, which is run by root.

share|improve this answer
    
perfect! but why you use egrep? mailq | wc -l - the same result or not? –  Alex Apr 8 '13 at 14:04
    
Try it ! The answer is no ! You have 4 lines by mail (active, deferred...). The star means active mails only. –  Dom Apr 8 '13 at 14:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.