반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 도커
- springboot
- Kubernetes
- ioredirection
- java
- variable
- docker
- bash
- devops #engineer
- aws #engineer
- 쿠버네티스
- multivm
- devops #jenkins
- nginx
- mongodb operator
- container
- Vagrant
- namespace
- 컨테이너
- python
- linux
- k8s
- Strimzi
- DOIK
- 파이썬
- 초간단파이썬
- RSS
- WEB
- httpd실행
- Engineer
Archives
- Today
- Total
샤인의 IT (막 적는) 메모장
[Linux] Process & Archive 본문
반응형
Process
#top - 동작중인 프로세스 및 리소스 확인
[root@localhost yum.repos.d]# top
top - 14:59:40 up 3:03, 1 user, load average: 0.00, 0.01, 0.05
#프로세스 정보
Tasks: 120 total, 1 running, 119 sleeping, 0 stopped, 0 zombie
#CPU 정보
%Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
#메모리 정보
KiB Mem : 498508 total, 111632 free, 119004 used, 267872 buff/cache
KiB Swap: 1048572 total, 1047028 free, 1544 used. 362948 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
868 root 20 0 437356 1828 1332 S 0.3 0.4 0:05.90 VBoxService
1943 vagrant 20 0 155044 2592 1160 S 0.3 0.5 0:07.11 sshd
2659 root 20 0 162124 2244 1536 R 0.3 0.5 0:00.02 top
1 root 20 0 128232 6496 3828 S 0.0 1.3 0:01.73 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
5 root 20 0 0 0 0 S 0.0 0.0 0:00.08 kworker/u4:0
6 root 20 0 0 0 0 S 0.0 0.0 0:00.77 ksoftirqd/0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.05 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:02.01 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 0:00.38 watchdog/0
12 root rt 0 0 0 0 S 0.0 0.0 0:00.57 watchdog/1
13 root rt 0 0 0 0 S 0.0 0.0 0:00.10 migration/1
14 root 20 0 0 0 0 S 0.0 0.0 0:02.99 ksoftirqd/1
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H
19 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kdevtmpfs
20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
21 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
...
#ps - 프로세스 확인
[root@localhost yum.repos.d]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 1.3 128232 6496 ? Ss 11:55 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0.0 0.0 0 0 ? S 11:55 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< 11:55 0:00 [kworker/0:0H]
root 5 0.0 0.0 0 0 ? S 11:55 0:00 [kworker/u4:0]
root 6 0.0 0.0 0 0 ? S 11:55 0:00 [ksoftirqd/0]
...
[root@localhost yum.repos.d]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:55 ? 00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0 0 11:55 ? 00:00:00 [kthreadd]
#kill - 프로세스 종료
[root@localhost yum.repos.d]# ps -ef | grep httpd
root 2631 1 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2632 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2633 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2634 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2635 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2636 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 2681 1972 0 15:03 pts/0 00:00:00 grep --color=auto httpd
[root@localhost yum.repos.d]# kill -9 2632
[root@localhost yum.repos.d]# ps -ef | grep httpd
root 2631 1 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2633 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2634 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2635 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2636 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2682 2631 0 15:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 2684 1972 0 15:03 pts/0 00:00:00 grep --color=auto httpd
# 해당 ps 출력 문자열을 슬라이싱 해서 명령어 수행
[root@localhost yum.repos.d]# ps -ef | grep httpd | grep -v 'grep'
root 2631 1 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2633 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2634 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2635 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2636 2631 0 14:56 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2682 2631 0 15:03 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
[root@localhost yum.repos.d]# ps -ef | grep httpd | grep -v 'grep' | awk ' {print $2}'
2631
2633
2634
2635
2636
2682
#xargs로 명령어 수행! ls는 테스트
[root@localhost yum.repos.d]# ps -ef | grep httpd | grep -v 'grep' | awk ' {print $2}' | xargs ls
ls: cannot access 2631: No such file or directory
ls: cannot access 2633: No such file or directory
ls: cannot access 2634: No such file or directory
ls: cannot access 2635: No such file or directory
ls: cannot access 2636: No such file or directory
ls: cannot access 2682: No such file or directory
[root@localhost yum.repos.d]# ps -ef | grep httpd | grep -v 'grep' | awk ' {print $2}' | xargs kill -9
[root@localhost yum.repos.d]# ps -ef | grep httpd | grep -v 'grep' # 프로세스 제거하고 없음
Archive
#tar -czvf (c)create (z)compress v(visual) f(file)
#tar 압축
[root@localhost log]# tar -czvf yum_log-20220115.tar yum.log-20220114
yum.log-20220114
[root@localhost log]# ls
anaconda btmp-20220114 dmesg.old maillog samba tallylog vboxadd-setup.log.2 yum_log-20220115.tar
audit chrony grubby maillog-20220114 secure tuned vboxadd-setup.log.3
boot.log cron grubby_prune_debug messages secure-20220114 vboxadd-install.log wtmp
boot.log-20220114 cron-20220114 httpd messages-20220114 spooler vboxadd-setup.log yum.log
btmp dmesg lastlog rhsm spooler-20220114 vboxadd-setup.log.1 yum.log-20220114
[root@localhost log]# file yum_log-20220115.tar.gz
yum_log-20220115.tar.gz: gzip compressed data, from Unix, last modified: Fri Jan 14 15:10:05 2022
[root@localhost log]# mkdir yum_log
[root@localhost log]# mv yum_log-20220115.tar.gz yum_log
[root@localhost log]# cd yum_log/
[root@localhost yum_log]# ls -alh
total 8.0K
drwxr-xr-x. 2 root root 37 Jan 14 15:10 .
drwxr-xr-x. 10 root root 4.0K Jan 14 15:10 ..
-rw-r--r--. 1 root root 2.5K Jan 14 15:10 yum_log-20220115.tar.gz
#tar 압축 풀기
[root@localhost yum_log]# tar -xzvf yum_log-20220115.tar.gz
yum.log-20220114
[root@localhost yum_log]# ls
yum.log-20220114 yum_log-20220115.tar.gz
[root@localhost yum_log]# ls -alh
total 20K
drwxr-xr-x. 2 root root 61 Jan 14 15:10 .
drwxr-xr-x. 10 root root 4.0K Jan 14 15:10 ..
-rw-------. 1 root root 12K Jan 14 12:09 yum.log-20220114
-rw-r--r--. 1 root root 2.5K Jan 14 15:10 yum_log-20220115.tar.gz
#zip / unzip
[root@localhost log]# zip -r httpd.zip httpd/
adding: httpd/ (stored 0%)
adding: httpd/error_log (deflated 68%)
adding: httpd/access_log (stored 0%)
adding: httpd/.zip (stored 0%)
[root@localhost log]# ls -alh
[root@localhost yum_log]# unzip httpd.zip
Archive: httpd.zip
creating: httpd/
inflating: httpd/error_log
extracting: httpd/access_log
extracting: httpd/.zip
[root@localhost yum_log]# ls -alh
total 8.0K
drwxr-xr-x. 3 root root 36 Jan 14 15:17 .
drwxr-xr-x. 10 root root 4.0K Jan 14 15:17 ..
drwx------. 2 root root 53 Jan 14 15:16 httpd
-rw-r--r--. 1 root root 1.2K Jan 14 15:16 httpd.zip
반응형
'Cloud Infra > Linux' 카테고리의 다른 글
[Linux] Package & Service (0) | 2022.01.15 |
---|---|
[Linux] User Group & Permission (0) | 2022.01.15 |
[Linux] File Type & IO Redirection (0) | 2022.01.15 |
[Linux] 기본 명령어 정리 (0) | 2022.01.15 |
[Linux] Rocky Linux 설치 (0) | 2021.05.15 |
Comments