
[ cron 이란 ? ]
특정 시간에 특정한 작업을 수행할 수 있게 해주는 프로그램이다.
대부분의 리눅스 배포판에 기본적으로 설치되어 있다.
내가 만약 매일 새벽 5시에 DB 백업을 받아야 한다고 가정한다면, 매일 DB 백업을
받기 위해 새벽 5시에 출근할 수는 없는 일이다. 이럴때 CRON 으로 작업을 스케줄링 해 놓
으면 cron 데몬이 알아서 백업을 받아준다.
[cron 설정하기 ]
RedHat 의 경우 /etc/crontab 이란 파일있다.
기본적으로 cron 데몬은 이 파일을 최초로 읽어 들인다.
[root@soma] vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
기본적인 crontab 내용이다.
[분] [시] [일] [월] [요일] [실행명령] 의 형식으로 이루어졌다.
위의 내용을 보면 /etc/crontab 을 읽어 들이면서 crontab 내용 안의 4 가지 파일을
설정된 시간에 맞춰서 실행한다.
1. 01 * * * * root run-parts /etc/cron.hourly
-> 매월,매일,매시,01 분에 /etc/cron.hourly를 실행한다.
2. 02 4 * * * root run-parts /etc/cron.daily
-> 매월,매일 4 시 02 분에 /etc/cron.daily 를 실행한다.
3. 22 4 * * 0 root run-parts /etc/cron.weekly
-> 매주일요일 4 시 22 분에 /etc/cron.weekly 를 실행한다.
4. 42 4 1 * * root run-parts /etc/cron.monthly
-> 매월 1일 4 시 42 분에 /etc/cron.monthly 를 실행한다.
[ 예제]
매일, 매시간10, 20 분에 /home/imsi/public_html/ 내의 모든 파일 및 디렉토리를
imsi.tar.gz 란 파일명으로 압축하고 나서 imsi.tar.gz 파일을 /home/imsi/back 이란
디렉토리로 이동하는 것을 설정해 보도록 하겠다.
1. /etc/crontab 설정하기
[root@tgs] vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
10,20 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
2. /etc/cron.hourly 스크립트 만들기
[root@tgs]vi /etc/cron.hourly/imsi
#!/bin/sh
tar cvfz /home/imsi/imsi.tar.gz /home/imsi/public_html/*
mv /home/imsi/imsi.tar.gz /home/imsi/back/
[ 옵션 사용하기 ]
1. crontab -l : 현재 설정되어있는 cron 의 리스트를 출력한다.
2. crontab -e : 이 옵션으로도 cron을 설정할 수 있다.
3. crontab -r : 이 옵션은 현재 설정되어있는 모든 cron 설정을 지운다.
etc/crontab 에 설정된 내용은 지워지지 않는다

7 TCP echo Echo
7 UDP echo Echo
9 TCP discard sink null Discard
9 UDP discard sink null Discard
13 TCP daytime Daytime
13 UDP daytime Daytime
17 TCP qotd quote Quote of the day
17 UDP qotd quote Quote of the day
19 TCP chargen ttytst source Character generator
19 UDP chargen ttytst source Character generator
20 TCP ftp-data File Transfer
21 TCP ftp FTP Control
23 TCP telnet Telnet
25 TCP smtp mail Simple Mail Transfer
37 TCP time Time
37 UDP time Time
39 UDP rlp resource Resource Location Protocol
42 TCP nameserver name Host Name Server
42 UDP nameserver name Host Name Server
43 TCP nicname whois Who Is
53 TCP domain Domain Name
53 UDP domain Domain Name Server
67 UDP bootps dhcps Bootstrap Protocol Server
68 UDP bootpc dhcpc Bootstrap Protocol Client
69 UDP tftp Trivial File Transfer
70 TCP gopher Gopher
79 TCP finger Finger
80 TCP http www, http World Wide Web
88 TCP kerberos krb5 Kerberos
88 UDP kerberos krb5 Kerberos
101 TCP hostname hostnames NIC Host Name Server
102 TCP iso-tsap ISO-TSAP Class 0
107 TCP rtelnet Remote Telnet Service
109 TCP pop2 postoffice Post Office Protocol - Version 2
110 TCP pop3 postoffice Post Office Protocol - Version 3
111 TCP sunrpc rpcbind portmap SUN Remote Procedure Call
111 UDP sunrpc rpcbind portmap SUN Remote Procedure Call
113 TCP auth ident tap Authentication Sevice
117 TCP uucp-path UUCP Path Service
119 TCP nntp usenet Network News Transfer Protocol
123 UDP ntp Network Time Protocol
135 TCP epmap loc-srv DCE endpoint resolution
135 UDP epmap loc-srv DCE endpoint resolution
137 TCP netbios-ns nbname NETBIOS Name Service
137 UDP netbios-ns nbname NETBIOS Name Service
138 UDP netbios-dgm nbdatagram NETBIOS Datagram Service
139 TCP netbios-ssn nbsession NETBIOS Session Service
143 TCP imap imap4 Internet Message Access Protocol
158 TCP pcmail-srv repository PC Mail Server
161 UDP snmp snmp SNMP
162 UDP snmptrap snmp-trap SNMP TRAP
170 TCP print-srv Network PostScript
179 TCP bgp Border Gateway Protocol
194 TCP irc Internet Relay Chat Protocol
213 UDP ipx IPX over IP
389 TCP ldap Lightweight Directory Access Protocol
443 TCP https MCom
443 UDP https MCom
445 TCP Microsoft CIFS
445 UDP Microsoft CIFS
464 TCP kpasswd Kerberos (v5)
464 UDP kpasswd Kerberos (v5)
500 UDP isakmp ike Internet Key Exchange (IPSec)
512 TCP exec Remote Process Execution
512 UDP biff comsat Notifies users of new mail
513 TCP login Remote Login
513 UDP who whod Database of who's logged on, average load
514 TCP cmd shell Automatic Authentication
514 UDP syslog
515 TCP printer spooler Listens for incoming connections
517 UDP talk Establishes TCP Connection
518 UDP ntalk
520 TCP efs Extended File Name Server
520 UDP router router routed RIPv.1, RIPv.2
525 UDP timed timeserver Timeserver
526 TCP tempo newdate Newdate
530 TCP,UDP courier rpc RPC
531 TCP conference chat IRC Chat
532 TCP netnews readnews Readnews
533 UDP netwall For emergency broadcasts
540 TCP uucp uucpd Uucpd
543 TCP klogin Kerberos login
544 TCP kshell krcmd Kerberos remote shell
550 UDP new-rwho new-who New-who
556 TCP remotefs rfs rfs_server Rfs Server
560 UDP rmonitor rmonitord Rmonitor
561 UDP monitor
636 TCP ldaps sldap LDAP over TLS/SSL
749 TCP kerberos-adm Kerberos administration
749 UDP kerberos-adm Kerberos administration
- bdb복구
- 디렉토리가 /data/fsesdata일때
- db_recover -c -v -h /data/fsesdat
오역이 있을지 몰라 발췌한 내용은 그대로 둠.
db_recover [-cefVv] [-h home] [-P password] [-t [[CC]YY]MMDDhhmm[.SS]]]
설명 : 예기치 않은 상황에서 DB 뻗었을 때 복구 하면 commit 된건 모두 살아나지만 commiitted 되지않은 트랜잭션은 온전히 완료되지 않음
옵션 설명 :
-c
Perform catastrophic recovery instead of normal recovery.
일반적인 복구가 아니고 완전 작살 났다고 판단될 때 사용
-e
Retain the environment after running recovery. This option will rarely be used unless a DB_CONFIG file is present in the home directory. If a DB_CONFIG file is not present, then the regions will be created with default parameter values.
복구 수행 후 환경을 유지. DB_CONFIG 파일이 홈 디렉토리에 있으면 거의 사용되지 않음. DB_CONFIG 파일이 없고 기본 세팅 값으로 새로운 홈디렉토리에 생성될 때 사용
-f(4.4이하 버젼은 지원 안함)
Display a message on the standard output showing the percent of recovery completed.
복구가 끝났을 때 복구된 퍼센티지를 터미널에 디스플레이
-h
Specify a home directory for the database environment; by default, the current working directory is used.
작업할 디비의 홈디렉토리 설정. 기본값은 현재 작업중인 디렉토리
-P
Specify an environment password. Although Berkeley DB utilities overwrite password strings as soon as possible, be aware there may be a window of vulnerability on systems where unprivileged users can see command-line arguments or where utilities are not able to overwrite the memory containing the command-line arguments.
디비 환경의 비밀번호 설정. 버클리 DB 유틸들은 가능하면 비밀번호를 덮어쓰긴 하지만 보안상 취약한 부분이 있음(그래서 어쩌라고...)
-t
Recover to the time specified rather than to the most current possible date. The timestamp argument should be in the form [[CC]YY]MMDDhhmm[.SS] where each pair of letters represents the following:
가장 최근의 복구 가능한 시간이 아닌 설정된 시간으로 복구. 타임스탬프는 다음 형태로 지정 [[CC]YY]MMDDhhmm[.SS]
CC
The first two digits of the year (the century).
년도에서 처음 두자리
YY
The second two digits of the year. If "YY" is specified, but "CC" is not, a value for "YY" between 69 and 99 results in a "CC" value of 19. Otherwise, a "CC" value of 20 is used.
년도에서 다음 두자리 CC 지정이 안된 상태에서 YY가 69~99 사이로 지정되면 CC는 19로 아니면 20으로 자동 세팅
MM
The month of the year, from 1 to 12.
1~12로 월 설정
DD
The day of the month, from 1 to 31.
1~31로 일 설정
hh
The hour of the day, from 0 to 23.
0~23으로 시간 설정
mm
The minute of the hour, from 0 to 59.
0~59로 분 설정
SS
The second of the minute, from 0 to 61.
If the "CC" and "YY" letter pairs are not specified, the values default to the current year. If the "SS" letter pair is not specified, the value defaults to 0.
0~61로 초 설정. CC와 YY가 설정 안되어 있으면 현재 년도가 기본값으로 사용됨. SS 설정을 안하면 기본값으로 0이 사용됨
-V
Write the library version number to the standard output, and exit.
기본 출력에 라이브러리 버젼 번호를 쓰고 나감.(먼소리야...)
-v
Run in verbose mode.
verbose 모드로 실행