Originally Posted by agouz
Hello, i would like to know if i can log or view the output of a running process, using ssh?
If you just want to log an ssh session that you invoke:
$ ssh -l login_name machine_name 2>&1 | tee ssh_logfile.txt
Graphical ssh clients (like Putty) may have session logging built in, but I've never looked for that so I don't know for sure.
Do you mean you want to invoke ssh, and then attach to an already running process on the remote machine and see what it's writing to stdout and/or stderr? You can use "truss" to see what's going on with a running process, but that shows the low level calls, not just stdout/stderr. You have to own the process (or be root) to do this. You could also try snooping around in /proc. I don't think you can grab only stdout/stderr from there, but I could very well be wrong on that. Again, you will either need to own the process or be root to see details under /proc.
If you mean the simpler "start a process and send it's output to a logfile":
$ program_name 2>&1 >logfile.txt
...to view and log at the same time:
$ program_name 2>&1 | tee logfile.txt