sys-watch.txt
3KB · 118 lines
[SE] watch �� ������ �ý��� �����
- �ۼ��� : ��ĥ�� <san2(at)linuxchannel.net>
- �ۼ��� : 2003.01.27
- �� �� : �ý��۰���(SE)
- �� �� : �ʺ�
- �� �� : watch �� �̿��� ������ �ý��� �����
- ���� : watch, �����
*��)
�� ������ ���� �ֽ� ���� �Ʒ� URL���� Ȯ���� �� �ֽ��ϴ�.
http://www.linuxchannel.net/docs/sys-watch.txt
-------------------------------------------------
watch - execute a program periodically, showing output fullscreen
(�ֱ����� ������ ��α� ���� ��ü ȭ�鿡 �����)
[Ȯ��]
$ which watch
/usr/bin/watch
$ rpm -qf `which watch`
procps-2.0.7-3 <-- �� �ý���� �� �����Ǿ�����.T.T
[���]
$ watch --help
Usage: watch [-dhnv] [--differences[=cumulative]]
[--help] [--interval=<n>] [--version] <command>
-d, --differences[=cumulative] highlight changes between updates
(cumulative means highlighting is cumulative)
-h, --help print a summary of the options
-n, --interval=<seconds> seconds to wait between updates
-v, --version print the version number
(������ ���ص� �ǰ��..^.^)
(�⺻������ 2�� ������� ȭ�� �����մϴ�.)
*�⺻ ��뿹)
$ watch [-d] [-n seconds] 'command...'
���� ������ ������ ���ô�.
�������, �ǽð�(1�ʰ���)���� �ٲ�� �ý���� UPTIME ���� ȭ�鿡 ���
����� ���ô�.
$ watch -d -n 1 'cat /proc/uptime'
Every 1s: cat /proc/uptime Sat Jan 4 14:41:18 2003
11554.91 11516.56
����� [Ctrl + C]�Դϴ�.
(���� ����ٸ�, -d �ɼ�� ��°�� ���ڱ���.)
/proc/uptime �ܿ�,
/proc/loadavg (�ý��� ���Ϸ� �����, `top`���� ����)
/proc/meminfo (�� ����)
...(��Ÿ)
�̹����� (`top`ó��) uptime�� loadavg�� �Ѳ����� ����� ���ô�.
(2�ʰ������)
$ watch 'cat /proc/{loadavg,uptime}'
....
(����)
�̹����� `tail -f`�� ���� �ǽð����� ��ȭ�� ���� ����
Ȯ���� ���ô�.
(��:/var/log/messages, root ���� �ʿ�)
$ watch -n 1 'tail -n 20 /var/log/messages'
....
(����)
�̹����� �ǽð����� ���ڸ� Ȯ���� ���ô�.
(��ɾ�: w, 2�� ����)
$ watch -d w
....
(����)
�̿� �������� �ý��� ��μ����� �ǽð����� Ȯ���� ���ô�.
(����ġ ��μ����� ����)
$ watch -d -n 1 'ps -ef | grep httpd | grep -v grep'
....
(����)
�̹����� netstat ��ɾ ����ؼ� �ǽð����� �����ִ�
�Ʈ(tcp/udp)�� �ش� ��α��� ������� ���ô�.
(�ý��ۿ� ���� root ���� �ʿ���)
# watch -d -n 3 'netstat -atnup'
....
(����)
���������� ��� �������� ��ɾ ������ ���ô�.
- ��� ������ ��� ���� ���
- httpd ��μ��� �ֱ� 20�� ���
- /var/log/messages �ֱ� 10 �� ���
- �߱� 2�� ����
- (root ����� �ʿ��ϰڱ���)
# watch -d 'w; echo; ps -ef | grep httpd | grep -v grep | tail -n 20;
echo; tail -n 10 /var/log/messages'
(��ɾ�� ';'�� ������, echo�� ������ ����ϱ� ���ؼ�)
(������� ������ ������ ������..)
(�ڱ⸸�� ����ũ��Ʈ�� �ۼ��� ������ ���ϰڱ���..���� �� �����ؼ�..)
E