Unix Execute Jobs at Specific Time in the Future
Most developers are familiar with cron
jobs, which is good for a job that needs to run periodically, like every Monday at 4PM.
But if you need to run a job at a specific time then you can use at
.
If we check the man
page for at
:
The at and batch utilities read commands from standard input or a specified file. The commands are executed at a later time, using sh(1).
at executes commands at a specified time;
at
relies on the atrun
demon which is disabled by default on Mac OS. In order for at
to run, you need to type this into a terminal console:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
CLI
$ at $(cat file) </path/to/script
Bash:
at $(< file) </path/to/script