6

I am looking for folders that act like cron jobs folders.

More specifically, I'm looking for all the different folders that run every file that exists under them and any user can write into them (like ~/Library/LaunchAgent, for example).

2 Answers 2

4

No, by default, there are no folders on macOS that allow any user to write into them, and then have the content executed automatically. This would be deemed a security risk by Apple.

cron and launchd

crontab exists on macOS. The use of cron is deprecated; Apple recommend launchd where possible.

With launchd each user has their own folder, ~/Library/LaunchAgents. Processes started through this mechanism are limited to the scope of the associated user's graphical user session.

launchd also provides locations for computer wide folders, see the manual page Files section on /Library/LaunchAgents and /Library/LaunchDaemons.

Watched Folders

macOS includes support for watched folders. These are likely the closest built-in solution to your description:

The ability to watch folders and take action on incoming items is a powerful automation technique that enables the creation of fully unattended workflows. A watched folder might be used, for example, to watermark incoming photos, convert them to PDF, and email them to clients for review. Many companies set up script servers—dedicated robot machines that watch folders and process detected items, allowing employees to offload tedious and repetitious work in order to focus on other important tasks.

In OS X, there are two primary ways to set up scripting-based watched folders: folder actions and stay open script apps.

0

MacOS Mojave and Catalina use launchd for managing daemons and agents. The folders managed by launchd are the following:

/System/Library/LaunchDaemons   # Apple-supplied system daemons
/System/Library/LaunchAgents    # Apple-supplied agents that apply to all users on a per-user basis
/Library/LaunchDaemons          # Third-party system daemons
/Library/LaunchAgents           # Third-party agents that apply to all users on a per-user basis
~/Library/LaunchAgents          # Third-party agents that apply only to the logged-in user

The best to know how to use it is to read the developer documentation here:

Launchd -- Apple Support

I think you answered to your question yourself: ~/Library/LaunchAgents is the folder for third-party users scripts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .