๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

"MacOS" ํƒœ๊ทธ๋กœ ์—ฐ๊ฒฐ๋œ 1๊ฐœ ๊ฒŒ์‹œ๋ฌผ๊ฐœ์˜ ๊ฒŒ์‹œ๋ฌผ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  ํƒœ๊ทธ ๋ณด๊ธฐ

ยท ์•ฝ 2๋ถ„

Crontab์œผ๋กœ ๋งค์ผ ์Šคํฌ๋ฆฐ์ƒท ๊ด€๋ฆฌํ•˜๊ธฐ#

ํ™˜๊ฒฝ#

  • MacOS + zsh

  • Google Drive File Stream (๋ฌด์ œํ•œ ์šฉ๋Ÿ‰)


๋ชฉ์ #

  • MacOS ์šฉ๋Ÿ‰ ๋ถ€์กฑ

  • ์ฐ์€ ์Šคํฌ๋ฆฐ์ƒท์ด๋‚˜ ๋™์˜์ƒ ๋ณด๊ด€

  • ํ•˜๋ฃจ๋งˆ๋‹ค ์Šคํฌ๋ฆฐ์ƒท ํด๋”์— ํŒŒ์ผ์ด ์Œ“์ด๋Š” ๊ฒƒ ๋ฐฉ์ง€

  • Dock์—์„œ ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ด€๋ฆฌ

์Šคํฌ๋ฆฐ์ƒท ์„ค์ •#

  • ์Šคํฌ๋ฆฐ์ƒท์˜ ์ €์žฅ ์œ„์น˜๋ฅผ ๊ตฌ๊ธ€ ๋“œ๋ผ์ด๋ธŒ ํŒŒ์ผ ์ŠคํŠธ๋ฆผ์˜ ํŠน์ • ํด๋”๋กœ ์ง€์ •

์‰˜ ์Šคํฌ๋ฆฝํŠธ#

  • screenshots ํด๋”์— ํŒŒ์ผ์ด ์žˆ์œผ๋ฉด

    • ๋ชจ๋‘ prev-screenshots๋กœ ๋ณต์‚ฌํ•œ๋‹ค.

    • screenshots ํด๋”์˜ ํŒŒ์ผ์„ ๋ชจ๋‘ ์ง€์šด๋‹ค (์ง€์šธ ๋•Œ confirm [y/n] ๋ฉ”์‹œ์ง€ ๋„์šฐ์ง€์•Š๊ฒŒ ์˜ต์…˜ ์„ค์ •)

  • ์—†์œผ๋ฉด ์—์ฝ”

~/scripts/mv_screenshots.sh

#!/bin/zsh
target=/Volumes/GoogleDrive/๋‚ด\ ๋“œ๋ผ์ด๋ธŒ/์ด๋ฏธ์ง€/screenshotsarchive=/Volumes/GoogleDrive/๋‚ด\ ๋“œ๋ผ์ด๋ธŒ/์ด๋ฏธ์ง€/prev-screenshots
if find "$target" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then    setopt localoptions rmstarsilent    cp -R "$target" "$archive/`date +\%Y-\%m-\%d`"    rm "$target"/*else    echo "Target '$target' is empty"fi

Bash checking if folder has contents

Why does rm -f ask me for confirmation on zsh?


ํฌ๋ก ํƒญ ์„ค์ •#

  • ๋งค์ผ ์˜คํ›„ 11:30์— ์‰˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์‹คํ–‰ํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋‹น์ผ์˜ ๋กœ๊ทธ ํŒŒ์ผ๋กœ ๊ธฐ๋กํ•œ๋‹ค.

crontab -e

30 23 * * * zsh ~/scripts/mv_screenshots.sh >> ~/log/job_`date +\%Y-\%m-\%d`.log 2>&1

์ž‘์—… ์Šค์ผ€์ฅด๋Ÿฌ ํฌ๋ก (Cron) ๊ฐ„๋‹จ ์‚ฌ์šฉ๋ฒ•

Crontab.guru - The cron schedule expression editor