Development/Shell script
[Linux][Shell script] while / for 예시, 조건문 -f / -d
Best Junior
2019. 7. 23. 15:10
result.txt 라는 파일이 없는 동안
do ~ done 실행
#!/bin/bash
while [ ! -f result.txt ]
do
echo "`ps -ef |grep python`" >> ./test.txt
sleep 1
done
파일은 -f
디렉토리는 -d
ps -ef ~~~ 명령어의 프로세스ID 값들을 가져와
각 값에 대해 kill -9 진행
#!/bin/bash
arr_stop_target_list=$(ps -ef |grep "test_for_ps" |grep -v "grep" |awk '{print $2}')
for target_stop in ${arr_stop_target_list};do
kill -9 $target_stop
done