Skip to content

Scripting & Automation

Scheduling (Task Scheduler, launchd, cron)

11 curated resources, easiest first.

Run bash (.sh) via launchd using a plist in /Library/LaunchAgents — by VikingOSX and etresoft on Apple Community

intermediateforum

VikingOSX shows a working LaunchAgent for a shell script: plist in ~/Library/LaunchAgents with 644 permissions, Label, RunAtLoad, StartInterval and full paths only. The original poster got theirs working after moving the script out of ~/Documents, and etresoft points to privacy permissions instead, noting shell scripts silently fail without Full Disk Access.

Run PowerShell as Scheduled Task — by Microsoft Q&A community (accepted answer, anonymous) with Rich Matheisen

intermediateforum

A script that worked by hand failed under Task Scheduler. The accepted answer says not to tick Do not store password when using Run whether user is logged on or not, since the task then cannot reach network resources, and to isolate the problem with a trivial test script and -noexit. Rich Matheisen recommends Start-Transcript for diagnosis and says two-factor authentication won't work in a scheduled task; the poster suspected a smart-card PIN prompt. No confirmed final fix is recorded.

Register-ScheduledTask — by Microsoft Learn

advancedpage

Reference for creating a Windows scheduled task from PowerShell by combining New-ScheduledTaskAction and New-ScheduledTaskTrigger with Register-ScheduledTask. It lists parameter limits (up to 32 actions and 48 triggers) and the Principal and RunLevel options for choosing the account and privilege level.

Troubleshooting the launch of local user XPC Launch Agent — by ktam and wjens on Apple Developer Forums

advancedforum

A 2015 thread with practical launchd debugging: a replier found that using ~ in ProgramArguments stopped the agent from starting while a full path worked, that the path should point at the executable inside the bundle, and the thread shows inspecting state with launchctl list, print and blame. Aimed at XPC agents, and the home-directory problem never got a firm root cause.