81 lines
2.5 KiB
Markdown
81 lines
2.5 KiB
Markdown
# `launchd` & `cron`
|
|
|
|
Currently all these scheduled jobs run on an up-to-date MacOS system. This means that `launchd` is the preffered method of scheduling jobs.
|
|
|
|
Sadly, `launchd` plist files exist at `~/Library/LaunchAgents/` which means if I sync these to this repository, they will polute standard linux home folders. (By default MacOS hides `~/Library`)
|
|
|
|
Eventually - I do plan on migrating my primary server to a linux-based system. But that costs money and the Mac it's currently running on was free.
|
|
|
|
## Backup launchd configuaration
|
|
|
|
```sh
|
|
launchctl remove launchd.restic # If it's already running
|
|
launchctl load -w ~/Library/LaunchAgents/launchd.restic.plist
|
|
launchctl list | grep restic
|
|
```
|
|
|
|
```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>launchd.restic</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>/bin/zsh</string>
|
|
<string>-c</string>
|
|
<string>source /Users/noahheague/.zshrc ; /Users/noahheague/.config/scripts/cron/backup-server.sh</string>
|
|
</array>
|
|
<key>StandardErrorPath</key>
|
|
<string>/Users/noahheague/launchd/restic-err.txt</string>
|
|
<key>StandardOutPath</key>
|
|
<string>/Users/noahheague/launchd/restic-out.txt</string>
|
|
<key>StartCalendarInterval</key>
|
|
<array>
|
|
<dict>
|
|
<key>Hour</key>
|
|
<integer>0</integer>
|
|
<key>Minute</key>
|
|
<integer>0</integer>
|
|
</dict>
|
|
</array>
|
|
<key>UserName</key>
|
|
<string>noahheague</string>
|
|
</dict>
|
|
</plist>
|
|
```
|
|
|
|
## DNS launchd configuaration
|
|
|
|
```sh
|
|
launchctl remove launchd.dns # If it's already running
|
|
launchctl load -w ~/Library/LaunchAgents/launchd.dns.plist
|
|
launchctl list | grep dns
|
|
```
|
|
|
|
```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>launchd.dns</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>/bin/zsh</string>
|
|
<string>-c</string>
|
|
<string>source /Users/noahheague/.zshrc ; /Users/noahheague/.config/scripts/cron/dns.sh</string>
|
|
</array>
|
|
<key>StandardErrorPath</key>
|
|
<string>/Users/noahheague/launchd/dns-err.txt</string>
|
|
<key>StandardOutPath</key>
|
|
<string>/Users/noahheague/launchd/dns-out.txt</string>
|
|
<key>StartInterval</key>
|
|
<integer>900</integer>
|
|
<key>UserName</key>
|
|
<string>noahheague</string>
|
|
</dict>
|
|
</plist>
|
|
```
|