Skip to content

Instantly share code, notes, and snippets.

@bynaki
Last active December 26, 2015 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bynaki/540879ce5662c2dc871c to your computer and use it in GitHub Desktop.
Save bynaki/540879ce5662c2dc871c to your computer and use it in GitHub Desktop.
ctime, mtime, atime - ctime: - mtime: - atime: - 파일의 ctime,

ctime, mtime, atime

우리는 대체로 이렇게 생각한다.

ctime : create time , mtime = modify time , atime = access time 이라고 생각한다.

하지만 이렇게 생각하면 안된다.

ctime:
  • 파일이나 inode 값이 바뀐 시점이다. 다시말해 속성값이 바뀐시점이다. 퍼미션이나 소유주, 파일크기 등 파일 속성값이 변경되었을 때 ctime 은 갱신된다.
mtime:
  • 파일의 수정시간이다. 이는 속성이 아닌 파일의 내용이 바뀌었을때 이 값이 바뀐다. 주의할 것은 파일 내용이 바뀌면 파일의 크기가 달라진다. 이때 파일의 크기가 속성이므로 ctime도 갱신된다. 만약 파일 내용을 수정했는데 파일 크기가 바뀌지 않았을수 있다. 이때는 ctime이 바뀌지 않을까? 파일이 수정되면 mtime 이 바뀐다. mtime 은 파일의 속성이다. 때문에 ctime이 바뀐다.

  • mtime은 대체로 ctime 과 같다. mtime이 갱신되면 ctime도 갱신된다. 하지만 ctime이 변경된다고 mtime이 변경되지는 않는다.

atime:
  • 파일을 오픈하면 atime이 갱신된다. grep , sort, cat 등등 명령을 주거나 open() 함수로 열었을때
파일의 ctime, mtime, atime을 쉘에서 ls로 확인법

ls의 옵션으로 -u 는 atime, -c는 ctime, 옵션이 없다면 mtime을 출력한다.

-u 와 -c 는 동시에 사용될 수 없다.

{"noteId":"151de59b2eb-542f0a5e","main":"151de59b2eb-542f0a5e.md","title":"ctime, mtime, atime - ctime: - mtime: - atime: - 파일의 ctime, mtime, atime을 쉘에서 ls로 확인법"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment