- 리눅스 자식생성 스크립트 proliferation.sh
1 소스 코드[ | ]
Bash
Copy
#!/bin/bash
if [ $# -eq 0 ]; then exit; fi
if [ $1 -lt 1 ]; then exit; fi
generation=$(($1 - 1))
bash ./$0 $generation &
bash ./$0 $generation &
bash ./$0 $generation &
sleep 600
2 실습[ | ]
Console
Copy
[root@zetawiki ~]# bash proliferation.sh 3 &
[1] 22712
Console
Copy
[root@zetawiki ~]# pstree 22712 -npA
bash(22712)-+-bash(22713)-+-bash(22744)---sleep(22760)
| |-bash(22745)---sleep(22754)
| |-bash(22746)---sleep(22763)
| `-sleep(22748)
|-bash(22714)-+-bash(22717)---sleep(22726)
| |-bash(22718)---sleep(22736)
| |-bash(22719)---sleep(22764)
| `-sleep(22720)
|-bash(22715)-+-bash(22721)---sleep(22730)
| |-bash(22723)---sleep(22740)
| |-bash(22731)---sleep(22747)
| `-sleep(22732)
`-sleep(22716)
Console
Copy
[root@zetawiki ~]# ps -ef | grep proliferation | grep -v grep
root 22712 21497 0 11:39 pts/0 00:00:00 bash proliferation.sh 3
root 22713 22712 0 11:39 pts/0 00:00:00 bash ./proliferation.sh 2
root 22714 22712 0 11:39 pts/0 00:00:00 bash ./proliferation.sh 2
root 22715 22712 0 11:39 pts/0 00:00:00 bash ./proliferation.sh 2
root 22717 22714 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22718 22714 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22719 22714 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22721 22715 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22723 22715 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22731 22715 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22744 22713 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22745 22713 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
root 22746 22713 0 11:39 pts/0 00:00:00 bash ././proliferation.sh 1
Console
Copy
[root@zetawiki ~]# ps -ef | grep proliferation | grep -v grep | awk '{print $2}' | xargs kill -9
[1]+ Killed bash proliferation.sh 3
- → 또는
kill -9 -22712
Console
Copy
[root@zetawiki ~]# ps -ef | grep proliferation
root 23106 21497 0 11:43 pts/0 00:00:00 grep proliferation
3 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- Bash (3)
로또번호 생성 ― Pinkcrimson리눅스 날짜 기준으로 파일 삭제하기 ― 백승현리눅스 날짜 기준으로 파일 삭제하기 ― Jmnote