๊ณต์์ฌ์ดํธ
A Simple Launchd Tutorial
launchd
ํ๊ฒํด๋ > pyํ์ผ ์์ฑ
title: [REF]bq_upload.py
#! /usr/bin/env python3
ํ๊ฒํด๋ > shell ํ์ผ ์์ฑ ๋ฐ ์คํ(chmod +x) ๊ถํ๋ถ์ฌ
title: [REF]bq_upload.sh
#! /bin/bash
export PATH=/Users/mori/anaconda3/bin:/Users/mori/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
source /Users/mori/anaconda3/etc/profile.d/conda.sh
conda activate socar
python [REF]bq_upload.py >> ./bq_upload.result.log
~/Library/LaunchAgents/plist ํ์ผ ์์ฑ
title: bq.upload.daemon.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>bq.upload.daemon.plist</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>30</integer>
<key>StandardErrorPath</key>
<string>ํ๊ฒํด๋/stderr.log</string>
<key>StandardOutPath</key>
<string>ํ๊ฒํด๋/stdout.log</string>
<key>WorkingDirectory</key>
<string>ํ๊ฒํด๋</string>
<key>ProgramArguments</key>
<array>
<string>./[REF]bq_upload.sh</string>
</array>
</dict>
</plist>
4.launchdctl์ ์ด์ฉํ์ฌ launchd๋ฅผ control
launchdctl load ~/Library/LaunchAgents/*.plist
launchdctl unload ~/Library/LaunchAgents/*.plist