B / Y / U / S
HOME 웹 호스팅 도메인 매뉴얼 고객지원 설정정보 계정신청 2025-05-21 Wednesday 
웹 호스팅
# 공지 사항
# 자주 묻는 질문
# 질문과 답변
# 가입 문의
커뮤니티
# 자유게시판
# 리눅스팁
# 아이큐 테스트
# 내홈 소개
# 겔러리
# 자료실

  리눅스팁  Go Unix Power Tools Online Book Go Bash Guide
Read No. 167 article 2002-07-06 06:18:06
NickName   풀비누
Subject   Unix's Timestamp
http://linux.co.kr/tips/content.html?
do=showall&msg_id=324&order=desc&cur_page=3&keyword=&search_option=

Title : Unix's Timestamp 
지현명, 2002/04/07 


▶ 유닉스의 세가지 시간 기본 개념 

-atime : File was last accessed(단순한 열람) 

-ctime : File's status was last changed(chmod, chown, touch ...) 

-mtime : File's data was last modified(화일의 데이터가 수정됨) 

(화일의 내용을 수정하면 ctime과 mtime이 동일하게 바뀐다.) 


▶ ls에서 시간확인 

-no_option : -mtime 
e.g.) #ls -al --full-time filename 
(-m옵션이 -mtime이 아닌 것은 default 옵션으로 되어 있기때문에) 

-c with -lt : sort by, and show, ctime 
e.g.) #ls -alc --full-time filename 

-u with -lt : sort by, and show, atime 
e.g.) #ls -alu --full-time filename 
(-u옵션은 use의 뜻이 담긴듯, -a옵션이 이미 사용되고 있어서) 


◐ 실전예제 ◑ 

// 예제화일 생성 
[ gwise@ns work]$ touch timetest 

// 기본시간 확인 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 12:28:09 2002 timetest 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 12:28:09 2002 timetest 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 12:28:09 2002 timetest 

// ctime의 변경 예제 
[ gwise@ns work]$ chmod 777 timetest 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rwxrwxrwx 1 gwise gwise 0 일 4월 07 12:28:09 2002 timetest* 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rwxrwxrwx 1 gwise gwise 0 일 4월 07 12:34:48 2002 timetest* 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rwxrwxrwx 1 gwise gwise 0 일 4월 07 12:28:09 2002 timetest* 

// mtime의 변경 예제(ctime도 같이 변함) 
[ gwise@ns work]$ echo "abc" >> timetest 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rwxrwxrwx 1 gwise gwise 4 일 4월 07 12:37:47 2002 timetest* 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rwxrwxrwx 1 gwise gwise 4 일 4월 07 12:37:47 2002 timetest* 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rwxrwxrwx 1 gwise gwise 4 일 4월 07 12:28:09 2002 timetest* 


▶ touch를 통한 시간 변경 
형식) -t [[CC]YY]MMDDhhmm[.ss] 
☞ touch를 실행하는 순간 ctime이 현재 시간으로 바뀜 

-no_option : mtime과 atime 동시에 변경 
e.g.) #touch -t 200204071200.00 timetest 

-a : change only the access time 
e.g.) #touch -a -t 200204071200.00 timetest 

-m : change only the modification time 
e.g.) #touch -m -t 200204071200.00 timetest 


◐ 실전예제 ◑ 

// 예제화일 생성 
[ gwise@ns work]$ touch timetest 

// 기본시간 확인 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:15:58 2002 timetest 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:15:58 2002 timetest 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:15:58 2002 timetest 

// -no_option 
[ gwise@ns work]$ touch -t 200204071200.00 timetest 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 12:00:00 2002 timetest 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:20:34 2002 timetest 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 12:00:00 2002 timetest 

// -a 
[ gwise@ns work]$ touch -a -t 200204071300.00 timetest 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 12:00:00 2002 timetest 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:22:38 2002 timetest 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rw-r--r-- 1 gwise gwise 0 금 4월 07 13:00:00 2002 timetest 

// -m 
[ gwise@ns work]$ touch -m -t 200204071313.00 timetest 
[ gwise@ns work]$ ls -al --full-time timetest |tr -s " " <- mtime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:13:00 2002 timetest 
[ gwise@ns work]$ ls -alc --full-time timetest |tr -s " " <- ctime 
-rw-r--r-- 1 gwise gwise 0 일 4월 07 13:23:52 2002 timetest 
[ gwise@ns work]$ ls -alu --full-time timetest |tr -s " " <- atime 
-rw-r--r-- 1 gwise gwise 0 금 4월 07 13:00:00 2000 timetest 


◐ 정 리 ◑ 

1. 화일의 내용을 수정하면 mtime/ctime 이 바뀜 
2. touch를 통해서 mtime과 atime을 변경하면 
ctime은 현재시간으로 바뀜 
3. ls의 default time은 mtime이다.
Regist Addr [ 211.110.41.183 ] 목록보기 윗글 아랫글
정규표현식 [ 상세 검색 ]
Page Loading [ 0.03 Sec ] SQL Time [ 0 Sec ]

Copyleft 1999-2025 by JSBoard Open Project
Theme Designed by IDOO And follow GPL2

개인정보 취급방침 이용 약관 사이트 맵 어드민 관리