httpd 를 확인하여 종료하기

root@www ~ [1.44 1.28]> ps -ef | grep httpd | grep -v grep
nobody    6570 25612  0 Dec04 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    6571 25612  0 Dec04 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    6572 25612  0 Dec04 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    9025 25612  0 Dec02 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    9026 25612  0 Dec02 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    9027 25612  0 Dec02 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    9028 25612  0 Dec02 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody    9031 25612  0 Dec02 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
nobody   24980 25612  0 Dec02 ?        00:00:00 /usr/local/httpd2/bin/httpd -k start
root     25612     1  0 Jul25 ?        00:00:03 /usr/local/httpd2/bin/httpd -k start



pid 만 구한다.

root@www ~ [1.44 1.28]> ps -ef | grep httpd | grep -v grep | awk '{print $2}'
6570
6571
6572
9025
9026
9027
9028
9031
24980
25612

종료 시그널 9번을 이용하여 모두 종료한다.

root@www ~ [1.44 1.28]> ps -ef | grep httpd | grep -v grep | awk '{print $2}' | xargs kill -9


다시 확인해 보면 실행된것이 없다.
root@www ~ [1.44 1.28]> ps -ef | grep httpd | grep -v grep


저작자 표시 비영리 동일 조건 변경 허락
신고

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret


[root@www test]# ls
1 2

 

[root@www test]# ls * | xargs -n1 -i cp {} /usr/local/src/test1
[root@www test]# ll /usr/local/src/test1/
total 8
-rw-r--r-- 1 root root 5 Nov 16 15:38 1
-rw-r--r-- 1 root root 5 Nov 16 15:38 2

 

 

[-n max-args]

[-i[replace-str]]

 

 

저작자 표시 비영리 동일 조건 변경 허락
신고

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret

url 이 아래와 같이 있다고 할때,

# cat list.txt 
naver.com
daum.net
google.co.kr

 

아래 처럼 실행하면, 모든 url 다운로드를 진행하게 된다.
# cat list.txt | xargs wget -c


--2012-11-16 14:24:09-- http://naver.com/
Resolving naver.com... 220.95.233.172, 220.95.233.171, 202.131.30.11, ...
Connecting to naver.com|220.95.233.172|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.naver.com/ [following]
--2012-11-16 14:24:09-- http://www.naver.com/
Resolving www.naver.com... 202.131.30.12, 202.131.30.11
Connecting to www.naver.com|202.131.30.12|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'

[ <=> ] 99,910 --.-K/s in 0.009s

2012-11-16 14:24:09 (10.6 MB/s) - `index.html' saved [99910]

--2012-11-16 14:24:09-- http://daum.net/
Resolving daum.net... 61.111.62.173, 110.45.215.23, 114.108.157.19, ...
Connecting to daum.net|61.111.62.173|:80... connected.
HTTP request sent, awaiting response... 302 Object Moved
Location: http://www.daum.net/ [following]
--2012-11-16 14:24:09-- http://www.daum.net/
Resolving www.daum.net... 110.45.215.15, 114.108.157.116
Connecting to www.daum.net|110.45.215.15|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'

100%[======================================>] 144,453 --.-K/s in 0.006s

2012-11-16 14:24:09 (24.7 MB/s) - `index.html' saved [144453]

--2012-11-16 14:24:09-- http://google.co.kr/
Resolving google.co.kr... 74.125.128.94, 2404:6800:4005:c00::5e
Connecting to google.co.kr|74.125.128.94|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.co.kr/ [following]
--2012-11-16 14:24:09-- http://www.google.co.kr/
Resolving www.google.co.kr... 74.125.128.94, 2404:6800:4005:c00::5e
Reusing existing connection to google.co.kr:80.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'

7% [=> ] 11,081 --.-K/s in 0.04s

2012-11-16 14:24:09 (297 KB/s) - `index.html' saved [144453]

FINISHED --2012-11-16 14:24:09--
Downloaded: 3 files, 380K in 0.05s (7.26 MB/s)

저작자 표시 비영리 동일 조건 변경 허락
신고

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret
Argument list too long

해당 디렉토리로 가서 아래 스크립트 실행

for file in $(ls)
do
    rm -fv $file
done


안써먹으니 이 간단한것도 기억에서 잊혀진다.


# find ./ -name "*.log" -print0 
./1.log./2.log

 

# find ./ -name "*.log" -print0 | xargs -0 rm -f
# ls

다 지워 졌음.

 

 

find 옵션

-print0
True; print the full file name on the standard output, followed by a null
character (instead of the newline character that '-print' uses). This
allows file names that contain newlines or other types of white space to be
correctly interpreted by programs that process the find output. This option
corresponds to the '-0' option of xargs.

 

 

xargs 옵션

--null, -0

Input items are terminated by a null character instead of by whitespace, and
the quotes and backslash are not special (every character is taken liter-
ally). Disables the end of file string, which is treated like any other
argument. Useful when input items might contain white space, quote marks,
or backslashes. The GNU find -print0 option produces input suitable for
this mode.

신고

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret

# find /home/jjangkbg -type f -mtime +60 | xargs tar -cvf /tmp/`date '+%d%m%Y'_archive.tar`
tar: Removing leading `/' from member names

/home/jjangkbg/hydra/list.php
/home/jjangkbg/hydra/hydra-6.5-src.tar.gz
/home/jjangkbg/hydra/hydra-6.5-src/hydra-cvs.o

...중략

[root@www jjangkbg]# ll /tmp/
total 11844
-rw-r--r-- 1 root root 12103680 Nov 15 14:26 15112012_archive.tar

 

 

저작자 표시 비영리 동일 조건 변경 허락
신고

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret