Monday, January 2, 2017

Finding your processes to learn how to determine the job numbers

`Finding your processes' to learn how to determine the job numbers of your background processes.

http://infohost.nmt.edu/tcc/help/unix/suspended.html

http://infohost.nmt.edu/tcc/help/unix/ps.html


  • To find the job numbers of all the background jobs you are running, type:
            % jobs
    The job numbers will be shown in square brackets ([]), followed by the notation ``Stopped'' (for suspended jobs) or ``Running'' (for jobs that are still executing).
  • To find out all the process ID numbers of processes you are running, type:
            % ps -gx
    Here is an example of output from this command:
              PID TT STAT  TIME COMMAND
            12030 p5 S     0:01 -csh (csh)
            12068 p5 T     1:46 emacs foo
            12788 p5 R     0:00 ps -gx
    The first column is the process ID. The second column tells what terminal is controlling it (in this case, ttyp5). Next comes the current status (S for sleeping, T for stopped, R for running). The next column tells how much time it has spent.

Resuming a suspended process

http://infohost.nmt.edu/tcc/help/unix/fg-bg.html

  • The bg command can be used to resume a suspended process in the background. When used with no arguments, the bg command will continue the last suspended job. To resume job number 2, you would type the command:
            % bg %2
  • The fg command resumes a suspended process in the foreground. For example, to resume job 1 in the foreground, you would type this command:
            % fg %1
  • You can also resume suspended processes by just typing a percent sign (%) followed by the job number. For example, the command %1 would resume job 1 in the foreground. This command:
            % %2&
    would resume job 2 in the background, because it ends with an ampersand.
Kill a suspended process as shown below:

       % kill %1

No comments:

Post a Comment