I’ve pieced together the following script:
ssh -2 -l root devserver "cd /var/log/httpd; ls | grep -v 'gz' | xargs -- tail -n 15"
This logs on to the devserver, chagnes directory to the httpd logs, lists them, removes the hundreds of compressed historical rotations, then pipes this in to tail.
Makes it easy to see what sort of errors are occurring. This works when I ssh in myself, then execute the commands in quotes. However, when using this as a script the output from production is garbled and I get notice chimes on dev, almost like it’s treating the output like a command rather than simple text.
I’m sure there’s some escaping or somesuch I’m missing.
Notes:
– SSHing in as root because the httpd logs aren’t readable by the usual ssh user.
– Because tail failed to find the files piped in from grep when I wasn’t in the directory in question.
To see which interpreter is used:
If ksh :
If bash
but if the list of arguments is too long, find must be used :