You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

How to transition from CRONTAB to Launchd on macOS?

I use an iMac M3 with Sequoia OS.

I have some tasks that I manage with CRONTAB.

Every now and then I read that Apple is going to remove this application and all this will have to be managed with LAUNCHD.


I've been trying to get this to work for quite some time now, but there's no way. The last thing I get is an error code 5 (Input/output error) when I try to load an agent.

Searching the Internet it seems that there are many more people in the same situation. From what I read I gather that from Sonoma onwards it stopped working.


The code I'm trying to get to work is a very simple one that appears in a tutorial on the Internet.

It is loaded in the /Users/user/Library/LaunchAgents directory and with PLUTIL the response is OK.


Any suggestions would be appreciated.


Regards



[Re-Titled by Moderator]

iMac 24″, macOS 15.0

Posted on Nov 10, 2024 11:31 AM

Reply
9 replies

Nov 12, 2024 8:39 AM in response to MacCG_84

MacCG_84 wrote:

Every now and then I read that Apple is going to remove this application and all this will have to be managed with LAUNCHD.

Where are you reading this? The internet? The internet is wrong.


Searching the Internet it seems that there are many more people in the same situation. From what I read I gather that from Sonoma onwards it stopped working.

No. It's just difficult to do.


The easy solution is to just use crontab. cron is still supported by Apple. In Sequoia, Apple even added a new flag in System Settings (Legacy Background Tasks) specifically to enable it.


If you want to use launchd anyway, you can do that too. You just have to know how launchd works. It isn't trivial. A significant portion of anything you hear about launchd on the internet will be wrong - guaranteed.


The code I'm trying to get to work is a very simple one that appears in a tutorial on the Internet.

Do you want to hear my opinion on Internet tutorials? 😄


But at a fundamental level, you haven't said anything, so there isn't anything anyone can say to help. What does your plist file look like? What is the script you are trying to run? Lead with that.

Nov 20, 2024 7:41 AM in response to MacCG_84

Thanks to a Canadian girl with the nickname Verpal, I already have a task running with Launchd.

In the examples I had seen so far, the second line was:


<!DOCTYPE plist PUBLIC ‘-//Apple//DTD PLIST 1.0///EN’>


Por lo que veo, la línea debería ser:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">


Finally I will be able to automate my backups.


Regards



Nov 12, 2024 11:16 AM in response to MacCG_84

When I use a Launchd plist, I place it and the script it is to run in the ~/Library/LaunchAgents folder. This folder name because this particular solution displays a dialog on the screen. I believe you will want to create a LaunchDaemons folder for solutions that have no graphical output.


Log out and log back in and if the syntax is correct, the operating system will run the .plist. Launchd is extremely fussy with correct syntax…

Nov 14, 2024 11:25 AM in response to VikingOSX

When I use a Launchd plist, I place it and the script it is to run in the ~/Library/LaunchAgents folder. This folder name because this particular solution displays a dialog on the screen. I believe you will want to create a LaunchDaemons folder for solutions that have no graphical output.


Thank you for your reply.

In my case, I don't think the problem has to do with syntax. Before upgrading to Sequoia I could load the plists, but when I executed them I got an error, I don't remember now which one.

Now it doesn't even allow me to load them.

I've read that the syntax has changed, and when I looked on Apple's development website, I found information, but from 2016.

The MAN page for launchd on the Apple website is dated 2019. On the Terminal, that information is from November 2013.


This must be for experts...

How to transition from CRONTAB to Launchd on macOS?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.