# command run on another terminal



## kr651129 (May 15, 2012)

Ok, weird question, but I was just wondering if this is possible.  Let*'*s say I have two terminals open and I run a command on one, while it's running is it possible to check the last executed command on that other terminal?  A random thought I had today and wouldn't mind knowing.


----------



## UNIXgod (May 15, 2012)

Look into something called a named pipe.


----------



## phoenix (May 15, 2012)

Read through the snp(4) and watch(8) man pages.

I've tested this with virtual consoles (outside of X).  Haven't tried using virtual terminals inside X.


----------



## egelor (May 15, 2012)

You can do it easy by checking *t*he history file on your login shell.


----------



## SirDice (May 16, 2012)

egelor said:
			
		

> You can do it easy by checking *t*he history file on your login shell.



That only shows which commands have been started. It doesn't show if they're still running and you also can't 'see' the output.

Simplest solution would be to use sysutils/tmux or sysutils/screen. I definitely recommend tmux(1).

On the second terminal you can *tmux att* and you'll see exactly the same *tmux* session as on the other terminal. You can even detach the session completely and everything running inside it will keep running. Easily picked up again from another terminal or even a remote SSH. Quite handy if you work on a remote machine that has a crappy connection.


----------



## jalla (May 16, 2012)

Not sure if it's what you're after, but w(1)() will show you the last command executed on each tty.


----------



## fluca1978 (May 16, 2012)

I think also sysutils/pstree can do the trick.


----------

