unix-config/.config/scripts/cron/README.md
2024-08-17 08:57:26 +10:00

1.6 KiB

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

launchctl remove launchd.restic # If it's already running
launchctl load -w ~/Library/LaunchAgents/launchd.restic.plist
launchctl list | grep restic
<?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/restic-err.txt</string>
    <key>StandardOutPath</key>
    <string>/Users/noahheague/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>