๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Computer Science/Linux (Ubuntu)

9 tar & find (+cron, at)

by Dowon Kang 2024. 1. 28.

 

tar command

tar ๋ช…๋ น์–ด๋Š” ์—ฌ๋Ÿฌ ํŒŒ์ผ๊ณผ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋ฌถ๊ฑฐ๋‚˜ ์••์ถ•ํ•˜์—ฌ ํ•˜๋‚˜์˜ ํŒŒ์ผ๋กœ ๋งŒ๋“œ๋Š” ์œ ์šฉํ•œ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ์•„๋ž˜์—๋Š” tar ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŒŒ์ผ์„ ๋ฌถ๊ณ , ๊ทธ๋ฆฌ๊ณ  ๋ฌถ์€ ํŒŒ์ผ์„ ํ•ด์ œํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๊ฐ„๋žตํ•œ ์„ค๋ช…์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

ํŒŒ์ผ ๋ฌถ๊ธฐ (tar)

 

-c: ์ƒˆ๋กœ์šด ์•„์นด์ด๋ธŒ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
-v: ์ƒ์„ธํ•œ ์ถœ๋ ฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค (์ƒ๋žต ๊ฐ€๋Šฅ).
-f: ์•„์นด์ด๋ธŒ ํŒŒ์ผ์˜ ์ด๋ฆ„์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

 

 

ํŒŒ์ผ ์••์ถ• ํ•ด์ œ (tar)

 

-x: ์•„์นด์ด๋ธŒ๋ฅผ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค.
-v: ์ƒ์„ธํ•œ ์ถœ๋ ฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค (์ƒ๋žต ๊ฐ€๋Šฅ).
-f: ์•„์นด์ด๋ธŒ ํŒŒ์ผ์˜ ์ด๋ฆ„์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

 

 

๋งŒ์•ฝ ๋‹ค๋ฅธ ๋””๋ ‰ํ† ๋ฆฌ์— ์ถ”์ถœํ•˜๋ ค๋ฉด ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•œ ํ›„ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•„์นด์ด๋ธŒ ํŒŒ์ผ์— ํฌํ•จ๋œ ํŒŒ์ผ๋“ค์ด /path/to/extract ๋””๋ ‰ํ† ๋ฆฌ์— ์ถ”์ถœ๋ฉ๋‹ˆ๋‹ค.



 

 

Find command 

find ๋ช…๋ น์–ด๋Š” ๋ฆฌ๋ˆ…์Šค์™€ ์œ ๋‹‰์Šค ๊ธฐ๋ฐ˜ ์‹œ์Šคํ…œ์—์„œ ํŒŒ์ผ ๋ฐ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๊ฐ•๋ ฅํ•œ ๋ช…๋ น์–ด์ž…๋‹ˆ๋‹ค. find ๋ช…๋ น์–ด๋Š” ๋‹ค์–‘ํ•œ ๊ธฐ์ค€์„ ์‚ฌ์šฉํ•˜์—ฌ ํŒŒ์ผ์„ ๊ฒ€์ƒ‰ํ•˜๊ณ , ์›ํ•˜๋Š” ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • [๊ฒ€์ƒ‰๊ฒฝ๋กœ]: ํŒŒ์ผ์„ ๊ฒ€์ƒ‰ํ•  ๋””๋ ‰ํ† ๋ฆฌ๋‚˜ ๊ฒฝ๋กœ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
  • [์˜ต์…˜]: ๊ฒ€์ƒ‰ ์˜ต์…˜์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
  • [๊ฒ€์ƒ‰์กฐ๊ฑด]: ๊ฒ€์ƒ‰ํ•  ํŒŒ์ผ์ด๋‚˜ ๋””๋ ‰ํ† ๋ฆฌ์˜ ์กฐ๊ฑด์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

 

์ฃผ์š” ์˜ต์…˜

 -name  ํŒŒ์ผ/๋””๋ ‰ํ† ๋ฆฌ ์ด๋ฆ„์œผ๋กœ ๊ฒ€์ƒ‰  find /path/to/search -name "filename.txt"
 -type  ํŒŒ์ผ ํ˜•ํƒœ๋กœ ๊ฒ€์ƒ‰ (f: ํŒŒ์ผ, d: ๋””๋ ‰ํ† ๋ฆฌ)  find /path/to/search -type f
 -mtime  ์ตœ์ข… ์ˆ˜์ • ์‹œ๊ฐ„์— ๋”ฐ๋ผ ๊ฒ€์ƒ‰  find /path/to/search -mtime -7
 -size  ํŒŒ์ผ ํฌ๊ธฐ์— ๋”ฐ๋ผ ๊ฒ€์ƒ‰  find /path/to/search -size +1M

 

์˜ˆ์‹œ

 

 

 


 

 

cron

cron์€ Unix ๋ฐ Unix ๊ณ„์—ด ์‹œ์Šคํ…œ์—์„œ ์ฃผ๊ธฐ์ ์œผ๋กœ ์ž‘์—…์„ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์Šค์ผ€์ค„๋Ÿฌ์ž…๋‹ˆ๋‹ค. cron์€ ์ •ํ•ด์ง„ ์‹œ๊ฐ„์— ์Šคํฌ๋ฆฝํŠธ, ๋ช…๋ น์–ด ๋˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ์˜ˆ์•ฝํ•ฉ๋‹ˆ๋‹ค. cron ์ž‘์—…์€ ํฌ๊ฒŒ ์‹œ๊ฐ„, ๋‚ ์งœ, ์š”์ผ ๋“ฑ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์Šค์ผ€์ค„๋ง๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” crontab ํŒŒ์ผ์„ ํ†ตํ•ด ์ž์‹ ์˜ cron ์ž‘์—…์„ ์„ค์ •ํ•˜๊ณ  ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • Cron Job: cron์— ์˜ํ•ด ์ฃผ๊ธฐ์ ์œผ๋กœ ์‹คํ–‰๋˜๋Š” ์ž‘์—…์„ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค.
  • Crontab: cron ์ž‘์—…์„ ์ •์˜ํ•˜๋Š” ํŠน๋ณ„ํ•œ ํŒŒ์ผ์ž…๋‹ˆ๋‹ค.

 

 

at

at ๋ช…๋ น์–ด๋Š” ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰ํ•  ์ž‘์—…์„ ์˜ˆ์•ฝํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. at ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰ํ•  ์Šคํฌ๋ฆฝํŠธ ๋˜๋Š” ๋ช…๋ น์–ด๋ฅผ ์ง€์ •๋œ ์‹œ๊ฐ„์— ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • at Job: at์— ์˜ํ•ด ์˜ˆ์•ฝ๋œ ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰๋˜๋Š” ์ž‘์—…์„ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค.

  • cron์€ ์ฃผ๊ธฐ์ ์ธ ์ž‘์—…์„ ์ •์˜ํ•˜๊ณ  ์ฃผ๋กœ ๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.
  • at์€ ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰ํ•  ์ž‘์—…์„ ์˜ˆ์•ฝํ•˜๋ฉฐ ์˜ˆ์•ฝ๋œ ์‹œ๊ฐ„์— ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

 

๋‘ ๋ช…๋ น์–ด๋Š” ์‹œ๊ฐ„์— ๋”ฐ๋ผ ์ž‘์—…์„ ์‹คํ–‰ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋˜์ง€๋งŒ, cron์€ ์ฃผ๊ธฐ์ ์œผ๋กœ, at์€ ํ•œ ๋ฒˆ๋งŒ ์‹คํ–‰๋˜๋Š” ์ž‘์—…์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.

 

 

 


tar

tar is a command-line utility in Unix and Linux environments used for bundling files and directories into a single archive file. It is often used in conjunction with compression tools like gzip to create compressed archives. The name "tar" stands for "tape archive," reflecting its historical use in archiving files onto magnetic tapes.

find
find is a command-line utility on Unix and Linux systems designed for searching and locating files and directories based on various criteria. It allows users to specify search conditions such as file name, type, modification time, size, and more. The find command is powerful for locating files in a directory hierarchy and performing actions on them, like executing commands or creating lists.

 

'Computer Science > Linux (Ubuntu)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

11 ์‘๊ธ‰๋ณต๊ตฌ (feat, GRUB ๋ถ€ํŠธ๋กœ๋”)  (0) 2024.02.08
10 Pipe, Filter, Redirection  (1) 2024.01.28
8 dpkg & apt  (1) 2024.01.28
7 Hard Link & Soft(symbolic) Link  (0) 2024.01.28
6 ํŒŒ์ผ ํ—ˆ๊ฐ€๊ถŒ(Permission)  (0) 2024.01.28

๋Œ“๊ธ€