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.

Like in the subject I got different result from the same grep command.
The following command is run on a central server which query the other servers via ssh.

ssh root@$domain "grep `date +%Y/%m/%d` /var/log/slave.log* | grep 'Blacklist\ requests,' | tail -1"  > "$current_dir"/servers_result

On different servers with the same Debian 6 in some case I've got no matches, instead in other case I've got the matches. I've checked the log and I can see that the entry exists.
Any thought?

share|improve this question
If root users on different servers have different shells then the * (asterisks) may be handled in different ways. Try to run in similar shells for start: ssh root@$domain dash -c "grep $(date +%Y/%m/%d) /var/log/slave.log* | grep 'Blacklist\ requests,' | tail -1" > "$current_dir"/servers_result –  Dmitry Vasilyanov Nov 19 '12 at 18:44
And if you run the command as root on the servers? Is the output as expected? –  jaume Nov 19 '12 at 22:00
You probably shouldn't allow root to login via ssh, just sayin... –  tjameson Nov 20 '12 at 2:54
@DmitryVasilyanov in my test it worked, but I want to see the results in the next 3 days. If everything goes well I'll give you the point ;) Cheers <br> jaume If I run the command on the server it works without problem –  marcodv Nov 20 '12 at 18:21
The bash folks will also scold you for using backticks... should be $(date...) these days, just sayin –  Keith Nov 20 '12 at 19:30

Your Answer


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

Browse other questions tagged or ask your own question.