Wednesday, September 19, 2012


How to run program in server even though our login session is over?

Usually  most people run android source code building from server via putty.
whenever we are giving build or any commands, it will not be executed once the putty session is over.

To avoid this, Linux has one most powerful command. That is screen.

we can use this screen command for various purposes.

screen syntax:
screen commandToBeExecuted


One more beauty of screen command is we can run our application and command in server, we can close the putty session. when we are reopening the putty session,
we can reattach that screen command & get results in ur putty.

For example while building I am getting some errors. One of my colleague is very well known how to resolve that error.Then I will go to his place and give "screen make" command(make is to build android code) while getting errors I will ask him to resolve it. when error is resolved, I can do "screen make" from his system. After this we will get build logs in his system.Not to disturb my colleague's work, I can detach the session from server, But still compilation will be done in background.I can go back to my seat and reattach the session, now the build process logs will be shown in my system.

To summarize:

From my friend's system I will do the following:

To build android code in server, I will give

screen make and will press ctrl+a and d then screen will print some id

  detached from 2309_pts-2

From my system, I will do the following:
  1) will open new putty session
  2) type "screen -r 2309_pts-2" [reattach the session]

Now the build logs will be shown in my system.


This screen command can be used for
  1) building the code even though the client session is over
  2) any background tasks activities can be done through it
  3) any big file downloads/android source code downloads can be done through it
     [In google chrome, there is an option called downloading the file in background even though the browser session is over]
4) To download android source code in background, i will do "screen repo sync", it will download the code in screen session


To list all the screen commands running in a server/system, we can use "screen -ls" command to list all the screen sessions running.




No comments: