Schedule task with atrun, launchd, at, atq, atrm, mail

Lets say you like to execute AS Script 20:00 today.

Setup atrun:
Copy /System/Library/LaunchDaemons/
to /Library/LaunchDaemons/

Open it with a Editor
and change the key Disabled to

now we run
launchctl load -F /Library/LaunchDaemons/

You also need to have file in /etc/at.allow
Inside this file you type your username

Now we have setup atrun and could use at, atq and atrm command.

We could now test it with bash script that execute AS Script with osascript
The security in macOS do not allow to display dialog if we do not use tell block.
So this example use System Events…

save the script somewhere… and maybe you need to do chmod +x

now we will setup at command for schedule… time: 20:00 today…

we type in command-line: at -f 20:00
if something like this return to us…
job 1 at Mon Jul 20 20:00:00 2020

we will also get notification to the local users mail…
we could read this from command-line: mail command

All this maybe look advance or complicated but its very powerful.
And its not so difficult to make handlers that use it, if do shell script do not work
you could try do script in terminal instead.

Ps. I have run the above example in terminal and not directly in Script Editor.

You maybe also need to make /usr/libexec/atrun and /usr/bin/at to have full disk access