![]() This is myĪttempt to gather all my knowledge about this in one place. Tutorials across the internet, trial and error, and the manuals. I have pieced together what I know about using launchd to schedule jobs from This is probably the bestįeature of launchd, because it allows me to run scripts on my iMac while still Is scheduled, it will run the job when it wakes up. So if your computer happens to be sleeping at the time a job Unlike cron, launchd does not assume that your computer It syncs my work files between myĪlmost anything you can do with cron you can do with launchd, but with more Every week it backs up the WordPressĭatabase of my “family pictures” blog. Every morning myĬomputer resets its volume to medium. Twitter statuses and check my library card for overdue books. Every day my computer is set to download my Other commands and options exist as well.Launchd is Apple’s replacement in OS X for several Unix process management Or command can be start or stop, to just start or stop such a task, in which case parameter is the label (-fancy-task). it is only kept alive as long as the program terminated with an exit code of zero, only as long as a certain file/directory on disk exists, only if another task is also alive, or only if the network is currently up.Īlso you can manually enable/disable tasks via command line: launchctl Ĭommand can be load or unload, to load a plist or unload it again, in which case parameter is the path to the file. If it has a dictionary value, you have a couple of extra options that give you more fine grain control under which circumstances the task shall be kept alive. The great new feature is, that it can also have a dictionary value instead of a boolean one. It can have a boolean value, in which case it is the exact opposite of OnDemand (setting it to false behaves as if OnDemand is true and the other way round). The new setting is named KeepAlive, which makes much more sense. Update: Even though OnDemand is still supported, it is deprecated. You can even limit how much resources a process may use (as said before, Lingon shows all these settings in a nice UI interface). You can also have task run on certain dates/times (basically launchd can do everything cron can do) or you can even disable “OnDemand” causing launchd to keep the process permanently running (if it quits or crashes, launchd will immediately restart it). This agent will run the shell script /usr/local/bin/my-script.sh every 1800 seconds (every 30 minutes). Just as an example, it could look like this If anyone knows a comparable tool that is freeware or open source, drop me a line in the comments and I will rather recommend that one (don’t want to advertise here for commercial software). This tool used to be free, now it costs $5 in the app store and $10 as the non app store version (the non app store version is much more powerful and if you already plan on paying for it, seriously, get the non app store version). Writing one per hand is suboptimal, you may want to get the free tool Lingon to create your tasks. This plist can have various options and settings. ![]() It should have reverse domain name notation. These are the directories where Apple places the launchd tasks that get your system up and running during boot, automatically start services as required, perform system maintenance tasks, and so on.Įvery launchd task there is a file in plist format. Messing around in the Systems folder can make your system unusable (get it into a state where it will even refuse to boot up again). You shall not place any files there, you shall not change any files there, unless you really know what you are doing. Note that there also exists /System/Library/LaunchDaemons and /System/Library/LaunchAgents, but as usual, everything under /System is managed by OS X. These task will run with your privileges, just as if you had started them yourself by command line or by double clicking a file in Finder. If they shall run only if you are logged in, they go to ~/Library/LaunchAgents/ If they shall only run if any user is logged in, they go to /Library/LaunchAgents/Īnd will be executed with the privileges of the user that just logged in. They will be started with “root” privileges. If they shall run, no matter if any user is logged in to the system or not. System tasks go to /Library/LaunchDaemons/ The location of the file depends on the questions: “When is this service supposed to run?” and “Which privileges will the service need?” ![]() Borrowing concepts of all these projects, yet also offering things you may not find elsewhere.Įvery service/task is a file. For those who are not familiar with launchd (or with OS X in general), it is like a crossbreed between init, cron, at, SysVinit ( init.d), inetd, upstart and systemd. It is a very powerful launcher system and meanwhile it is the standard launcher system for Mac OS X (current OS X version wouldn’t even boot without it). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |