Python 파일 주중 오전 10시 실행
bash
0 10 * * 1-5 /usr/bin/python3 /home/gitsam/test.py >> /home/gitsam/test.log 2>&1포인트:
1-5→ 월~금만 실행 (토, 일 제외)/usr/bin/python3경로는which python3으로 확인 권장>> ... 2>&1→ stdout + stderr 모두 로그 파일에 누적 저장
Tailscale 감시 및 자동 재시작 (오전 9시)
bash
0 9 * * * systemctl is-active --quiet tailscaled || (systemctl start tailscaled && echo "[$(date)] tailscaled restarted" >> /var/log/tailscale_watchdog.log)포인트:
tailscaled→ Tailscale의 실제 systemd 서비스명systemctl is-active --quiet→ 실행 중이면 아무것도 안 함, 죽었으면||이후 실행- 재시작 시 타임스탬프와 함께 로그에 기록
사전 확인 명령어:
bash
# 서비스명 확인
systemctl list-units | grep tailscale
# 현재 상태 확인
systemctl status tailscaledcrontab 적용:
bash
crontab -e # 위 라인 붙여넣기
crontab -l # 등록 확인crontab -e편집 시 환경변수(PATH등)가 쉘과 다를 수 있으므로, 명령어는 절대경로 사용을 권장합니다.