Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get access of process running on one terminal from other terminal in Linux?

I want to know the procedure so that i can access or get control from terminal over the process running on some other terminal in Linux .

  • Both terminals belong to same system .
like image 828
Praveen Avatar asked Nov 16 '11 06:11

Praveen


People also ask

Which command is used to view running processes?

You can use the ps command to find out which processes are running and display information about those processes. The ps command has several flags that enable you to specify which processes to list and what information to display about each process.

How do you check background process output?

You can use the below line to check what your process is doing. $ strace -p $! $! gives the process ID of the last background process.

How do I see what processes are running in Unix?

Open the terminal window on Unix. For remote Unix server use the ssh command for log in purpose. Type the ps aux command to see all running process in Unix. Alternatively, you can issue the top command to view running process in Unix.


2 Answers

Pehaps you want something like reptyr? (https://github.com/nelhage/reptyr)

You simply type reptyr PID to 'gain control' of another process (like vim or whatnot).

Edit:

This question has more information on using screen or tools like reptyr.

like image 56
onionjake Avatar answered Sep 18 '22 15:09

onionjake


Use the screen utility to start any process from terminal, so that you can access the same process from any other terminal either locally or remotely. For instance:

From first terminal

  1. Start a screen using screen -dR test and hit Enter, you will get shell within in screen.
  2. Run you program here

From second terminal

  1. Get in to existing screen using screen -x test

Now you should be able to see process running on first terminal, and will have the full control over that process.

You can investigate more on screen utility… its a very useful tool for any system administrator.

Hope the above tip will help you.

like image 27
abhi_ksd Avatar answered Sep 20 '22 15:09

abhi_ksd