I made an app (tested it works) and I want to make it run every day at midnight. Here is my PLIST file:
EDIT: after using @user3439894's code here is what I put in my 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>com.example.exampled</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-a</string>
<string>/Applications/Calculator.app</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</array>
</dict>
</plist>
When I run it using sudo launchctl load /Users/fbisurveillancevan/Desktop/LaunchMessageText.plist
, it returns nothing. When I try again, it returns launchctl: already loaded
The daemon/agent appears to be loaded, but does not run
Best Answer
In addition to the comments I've made to your OP, use this example to fix the issues you are having.
As a test, in Terminal, I executed the following commands:
Copy and paste the following example PLIST XML code into the opened
com.example.exampled.plist
file, setting theStartCalendarInterval
for a few minutes from now, and then save and close it.Back in Terminal, execute:
Now Calculator will open at the set time, which is set using 24 Hour time, e.g
0
through23
for the Hour key.macOS Catalina Notes:
In a clean install of macOS Catalina,
~/Library/LaunchAgents
doesn't exist by default. Use the following command beforecd ~/Library/LaunchAgents
:Due to changes made by Apple in macOS Catalina the fully qualified pathname for the Calculator is:
/System/Applications/Calculator.app
Change:
To:
Or as an alternative, just use:
Additional testing was done with an application bundle (myApp.app) created by me, saved in
/Applications
on macOS Catalina, and the following values worked for me:Or:
Note: The use of
sudo
is required when dealing with agents and daemons that are in the designated locations other then~/Library/LaunchAgents
in order to create, modify, change permissions to make read-only, delete, etc. the XML Plist file itself. Also note that when using thelaunchctl
command for daemons,sudo
may be required in some cases, however do not usesudo
toload
agents withlaunchctl
, as it will load them as a daemon.To review the manual pages, in Terminal, use
man command
wherecommand
is the commands name, e.g.man launchctl
, or to more easily read the manual pages, just type the commands name and right-click on it selecting: Open man PageIf you are going to use Launch Agents and Launch Daemons, I highly recommend you read the manual pages for
launchctl
,launchd.plist
andlaunchd
.Per the manual pages for
launchctl
andlaunchd.plist
the PLIST files for Launch Agents and Launch Daemons belong in specific directories:There is also an example xml property lists file at the end of the manual page for
launchd.plist
.