ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • HPUX - Process Control
    IoT 과정 2017. 6. 22. 16:56
    반응형

    A UNIX "process" is an instance of a running program

    Listing Process : ps, top

    {

    $ top

    System: vm189                                         Thu Jun 22 17:28:09 2017

    Load averages: 2.54, 2.72, 3.67

    214 processes: 149 sleeping, 65 running

    Cpu states:

    CPU   LOAD   USER   NICE    SYS   IDLE  BLOCK  SWAIT   INTR   SSYS

     0    2.66   0.2%  99.2%   0.6%   0.0%   0.0%   0.0%   0.0%   0.0%

     1    2.41   1.8%  96.4%   1.8%   0.0%   0.0%   0.0%   0.0%   0.0%

    ---   ----  -----  -----  -----  -----  -----  -----  -----  -----

    avg   2.54   1.0%  97.8%   1.2%   0.0%   0.0%   0.0%   0.0%   0.0%


    System Page Size: 4Kbytes

    Memory: 481420K (203968K) real, 858700K (359832K) virtual, 309396K free  Page# 1

    /20


    CPU TTY     PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU COMMAND

     1   ?     5072 user7    249 24  4008K   236K run     11:18 61.66 61.55 user7.ou

     1 pts/ts  5287 user6    249 24  4008K   236K run    

    .....

    }

    Starting Process in the Background : cmd.out &

    $ cat a.c

    main(){

      for(;;);

    }

    $ cc a.c -o user11.out

    $ user11.out &

    [1]     4086


    Moving Jobs to the Back/Foreground : bg and fg

    $ jobs
    [5] +  Running                    user11.out &
    [4] -  Running                    user11.out &
    [3]    Running                    user11.out &
    [2]    Running                    user11.out &
    [1]    Running                    user11.out &
    $ fg %1
    user11.out
    //ctrl + z
    [1] + Stopped                     user11.out &
    $ jobs
    [1] + Stopped                     user11.out &
    [5] -  Running                    user11.out &
    [4]    Running                    user11.out &
    [3]    Running                    user11.out &
    [2]    Running                    user11.out &

    Starting Process in the Background : nohup

    $ nohup user11.out &

    Sending output to nohup.out

    [1]     4741

    $ ps -ef |grep user11.out
      user11  4741  4619 246 16:56:45 pts/tm    0:15 user11.out
    $ exit
    There are running jobs.
    $ exit
    //re - login
    $ ps -ef |grep user11.out
      user11  4741     1 255 16:56:45 ?         0:23 user11.out

    //내 쉘이 종료된후 user11.out 의 부모는 init 프로세스가된다

    Termination Processes : kill

    $ ps -ef |grep user11.out

      user11  4741     1 254 16:56:45 ?         1:59 user11.out

    $ kill 4741

    $ ps -ef |grep user11.out

      user11  5264  4919  0 17:10:35 pts/tu    0:00 grep user11.out


    $ user11.out &

    [1]     5409

    $ ps -ef |grep user11.out

      user11  5409  4919 245 17:14:22 pts/tu    0:04 user11.out

      user11  5414  4919  0 17:14:32 pts/tu    0:00 grep user11.out

    $ kill -s INT 5409

    $

    [1] + Interrupt                   user11.out &



    $ user11.out &
    [1]     5421
    $ ps -ef |grep user11.out
      user11  5421  4919 244 17:15:06 pts/tu    0:07 user11.out
    $ kill -9 5421
    $
    [1] + Killed                      user11.out &


    Prioritizing Processes: nice

    process priorities(HPUX)  0~fg20(bg24)~39

    Good ~ Bad (Good 일수록 자주 CPU를 할당받는다)


    A(0)  100   (100)AAA(200)     (100)AAA(200)      (100)AAA(200)       

    B(20) 150               (130)BBB(200)      (100)BBB(200)       (180)      (160)

    C(39) 200               (195)     (190)      (185)      (180)      (175)CCC(170)


    //nice와 renice에서 값 감소(cpu사용도 좋아짐) 은 root만이 가능하다.


    Scheduling Processes : cron

    Use the cron daemon to schedule and automate routine system tasks

    /var/adm/cron/cron.allow [사용자의 이름이 있어야 함]

    cron Example

    min : 분, * 매분 

    hour : 시, * 매시

    date : 일, * 매일

    month : 월, * 매월

    day: 요일, * 매요일 [0 일, 1 월, 2 화, ... , 6 토]

    command: 반드시 절대경로로 표현, 출력시 기호 > 표준출력지정 [ps -ef | grep cron, then cron's tty is unknown]

    {

    $ crontab -e

    ~ vi mode

    * * 23 6 * /usr/bin/date >> /home/user11/cron.out # 2017.6.23

    //cron files are stored in /var/spool/cron/crontabs/"username"

    $ tail -f cron.out

    Fri Jun 23 10:46:00 KST 2017

    Fri Jun 23 10:47:00 KST 2017

    Fri Jun 23 10:48:01 KST 2017

    }


    Scheduling Process : at

    Use the at command to schedule on-time command execution

    {

    $ at now + 12 hours

    mkdir /home/user11/atdir

    cp /etc/passwd /home/user11/atdir

    date > /home/user11/atdir/at.out

    // at은 실행어를 상대경로로 표현가능

    5 minutes later ...

    $ cd atdir
    $ ls
    at.out  passwd
    $ cat at.out
    Fri Jun 23 10:48:13 KST 2017

    }

    반응형

    'IoT 과정' 카테고리의 다른 글

    HPUX - Shell Programming - Branches  (0) 2017.06.23
    HPUX - Shell Programming  (0) 2017.06.23
    HPUX - Process Control  (0) 2017.06.22
    HPUX - Pipes  (0) 2017.06.22
    HPUX - Input and Output Redirection  (0) 2017.06.22
    HPUX - Quoting  (0) 2017.06.21

    댓글 0

Designed by Tistory.