Skip to content

Instantly share code, notes, and snippets.

@jiwnchoi
Created September 21, 2024 05:13
Show Gist options
  • Save jiwnchoi/ffa64679d833d13f0202d00767db0dbc to your computer and use it in GitHub Desktop.
Save jiwnchoi/ffa64679d833d13f0202d00767db0dbc to your computer and use it in GitHub Desktop.
# 주간 업데이트 함수
weekly_update() {
# 마지막 실행 시간을 저장할 파일
last_run_file="$HOME/.last_weekly_update"
# 현재 시간
current_time=$(date +%s)
# 파일이 존재하지 않으면 생성
if [ ! -f "$last_run_file" ]; then
echo 0 > "$last_run_file"
fi
# 마지막 실행 시간 읽기
last_run_time=$(cat "$last_run_file")
# 일주일(7일)을 초로 계산
week_in_seconds=$((7 * 24 * 60 * 60))
# 마지막 실행 후 일주일이 지났는지 확인
if [ $((current_time - last_run_time)) -ge $week_in_seconds ]; then
echo "주간 업데이트 실행 중..."
brew update
pnpm update -g --latest
echo $current_time > "$last_run_file"
fi
}
# zsh 시작 시 weekly_update 함수 실행
weekly_update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment