I just want to simply run a mv
command everyday at midnight (this is unrelated to my other posts in case you were wondering), but if my Mac is asleep or off and it misses that time, then it runs the command as soon as it can once it wakes up / turns on and I'm logged in. I know cron is popular utility for doing this, but macOS launchd, which is supposed to replace cron.
Cron is used a lot on Linux distros and I imagine that a lot of guides I find for cron and questions on SO / StackExchange would apply to macOS as well, especially if I installed it with brew install cron
. However Launchd has a lot more to it than scheduling tasks from the little bit of reading I've done, should I use it if its possible I'd want to do other things with Launchd in the future? Possibly use it macOS tasks or automations for things I'd do in the future but not today?
Which is simpler, and which would you recommend?
By - TheTwelveYearOld
Launchd will give you more control: you can schedule when a mac powers up, shuts down, and probably when it sleeps. It's been ages since I've used a mac though.
I used cron on a Mac for years running brew updates. No problems. Install cron, `0 0 * * * mv /home/me/Downloads/ /.pr0n/` Done
I'm a macos user and though I love cron more than launchd (I've used Linux systems longer than I have the macOS systems), why have two systems that do the same thing? Just use launchd and use the program LaunchControl (https://soma-zone.com/LaunchControl/) to create the entries you need. It makes launchd so easy to use.
If you think about it what is cron launched by? I'd say launchd for more control cron for compatibility with linux (if it's needed of course)
I’d use cron as it’s specifically built for your use case. I haven’t used it a ton but my take is that launchd is the macOS equivalent of systemd as in its likely the main process that keeps things running and helps you interact with the system at a lower level
[удалено]
Agreed, modulo complexity. Any time I need to change my launchd stuff I need to start reading up on it. Would be great if there was a set of utilities one could use to maintain it.
I personally use Hammerspoon which allows you to do everything cron or launchd do in an very accessible language (lua)