61.Linux2008. 7. 22. 09:35
반응형
Daemon and Process

- Daemon : 커널상에서 백그라운드 모드로 작동하여 비활성화 상태에서 요청이 있을 때만 동작하는 프로세스를 일컬음

- Xinetd (extended inetd)
  super daemon
  http://www.xinetd.org
  yum install xinetd
  # cat /etc/xinetd.conf
  # cat /etc/xinetd.d/
  # /etc/init.d/xinetd (re)start
  # chmod 600 /etc/xinetd.conf : change the permission
  # chmod 600 /etc/xinetd.d/*
  # chattr +i /etc/xinetd.conf : disallow to modify the file
  # chattr +i /etc/xinetd.d/*
  http://www.macsecurity.org/resources/xinetd/tutorial.shtml : reference to xinetd superdaemon

- Process : 커널 상에서 동작하고 있는 모든 프로그램 (PID, Process ID)
  # ps
  # ps -ef
  # ps aux or ps axj

- Kill process
  # kill -9 973 or kill -SIGKILL 973 : terminate the PID process
  # kill -1 973 or kill -SIGHUP 973 : restart the PID process

- # ps ax | grep syslogd

- BG and FG
  # jobs : check if there are background process working
  # fg %작업번호 : bg -> fg
  # bg %작업번호 : fg -> bg
  Ctrl+Z : process interrupt

- # pstree : print working processes in forms of tree
  # top : monitor the working processes realtime

- Management of daemon
  부팅시 자동적으로 데몬이 적재
  # /usr/sbin/ntsysv
  # /usr/sbin/chkconfig
  Alt+F2 -> 'system-config-services'

- Daemon example 1 (at daemon)
  : 작업 스케쥴 예약
  # /etc/init.d/atd restart
  # at 10:00pm today (at now + 4 hours)
  at> shutdown -r now
  at> ctrl+D
  # cat /etc/at.allow : 사용자 제한
  # atq (at -l) : at로 예약한 작업 리스트 확인
  # atrm 작업번호 : 예약중인 at 작업 중지

- Daemon example 2 (cron daemon)
  : 같은 작업을 주기적으로 반복하여 처리
  # /etc/init.d/crond restart
  # crontab -l : print crontab content
  # crontab -e : edit the cron schedule (using vi editor)
  0 12 * * 6 /home/ekyulee/back.sh : 토요일마다 자신의 디렉토리를 백업
  0 12 1-12/2 * /home/ekyulee/back.sh : 1월부터12월까지 2개월마다 디렉토리 백업
  # cat /etc/crontab
  01 * * * * root run-parts /etc/cron.hourly
  02 4 * * * root run-parts /etc/cron.daily
  22 4 * * o root run-parts /etc/cron.weekly
  42 4 1 * * root run-parts /etc/cron.monthly
  # cat /etc/cron.allow

출처 : http://thesimple.tistory.com/55
Posted by 1010