일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- jetpack compose
- androidx
- Streaming
- FSM
- recyclerview
- 넷플릭스
- Freesound
- kotlin
- 명심보감
- Coroutine
- 명언모음
- Linux
- 파이썬
- 이모지메모
- bash
- 공자명언
- ASMR
- Flutter
- Firebase
- 좋은글필사하기
- DART
- 1인개발자
- 공부집중
- 이모지
- 소울칼리버6
- 장자명언
- 벤자민플랭클린
- Android
- 오픈소스
- 코틀린
Archives
- Today
- Total
Vintage appMaker의 Tech Blog
우분투에서 프로세스 죽이기 - bash 본문
VintageAppMaker/processkill_bash
process 죽이기 bash 예제. Contribute to VintageAppMaker/processkill_bash development by creating an account on GitHub.
github.com
간단한 프로세스 죽이기 스크립트 소스.
#!/bin/bash
print_msg()
{
colors=("\e[1;32;40m$1\033[0m" "\e[1;32;45m$1\033[0m" "\e[1;34;48m$1\033[0m")
echo -e ${colors[$2]}
}
# parameter 채크하기
if [ $# -lt 1 ]; then echo -e "uses: $0 \e[1;32;40m[process name]\033[0m"; exit; fi
#구분자를 캐리지리턴으로 한다.
OLDIFS=$IFS
IFS='
'
plist=$(ps -A | grep $1)
numlist=()
count=1
for indx in ${plist[@]}
do
print_msg "$count) $indx" 0
IFS=$OLDIFS
n=$(echo $indx | awk '{print $1}')
numlist[$count]=$n
((count++))
done
size=${#numlist[@]}
if [ $size -eq 0 ]
then
echo -e "($1) is not founded."
exit
fi
print_msg "choice you want to kill process." 2
read n
# null 채크한다.
if [ -z $n ]; then exit; fi
# 문자인지 숫자인지 채크한다. 1이면 문자.
let $n; rst=$?
if [ $rst -eq 1 ]; then exit; fi
# 배열범위를 넘어서는지 채크한다.
if [ $n -gt $size ]; then exit; fi
kill ${numlist[$n]}
'Source code or Tip > Linux' 카테고리의 다른 글
linux bash 정리 (0) | 2020.07.18 |
---|---|
linux bash에서 logcat 사용하기 - Android (0) | 2020.07.16 |
Comments