2018년 2월 20일 화요일

Process 관리

Process 관리


실행


$ ./program

Background 로 실행


$ ./program &

Background 로 보내기


Ctrl+z

일시 정지됨

Background 에서 실행


$ bg

Foreground 로 불러오기


$ fg

Interrupt 날리기


Ctrl+c

  • 보통 process 가 정지되지만 process 에서 무시 처리하는 경우 있음

Job 목록 확인


$ jobs


stdin redirect


$ ./program < myfile

stdout redirect


$ ./program > myfile.log

또는 무시

$ ./program > /dev/null

stderr redirect


$ ./program 2> myerror.log

stdin 과 stderr 를 같게


$ ./program > /dev/null 2>&1

 

 PID 확인

 

$ ./program &
$ echo $!

Process 목록


ps

모든 process 목록

ps aux

Process 이름으로 PID 찾기


$ pidof $PROCESS_NAME

$ pgrep $PROCESS_NAME

$ pgrep -f $KEYWORD

 

Process 죽이기


$ kill $PID

$ pkill $PROCESS_NAME

$ pkill -f $KEYWORD

$ killall $PROCESS_NAME

Process 실행 정보 위치


$ ls /proc/$PID/

  • status 및 stat, statm, cmdline 등 process 관련 여러 파일들이 존재

2018년 2월 7일 수요일

linux 배포 버전 확인

linuax 배포 버전 확인

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial