Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Utilities (Apple) Businesses OS X Operating Systems Software Unix Apple

Does launchd Beat cron? 798

Blamemyparents writes "For those who aren't Appleheads, you may not have heard that with Tiger, Apple swapped out old Unix standby cron for their own creation, launchd (Apple mentions it on their OS X page and has the man page for it up as well). Seems like it's a bit nerdy, but this changes a LOT about how *nix systems have done things for many years. Launchd is Apple's replacement for quite a few utilities, including launching and quitting quite a few different things, and getting info from the system and other running processes. This page from Ars Technica talks a bit more in depth about it. Apple has open sourced the thing, and is apparently hoping all the unix kids will take a look."
This discussion has been archived. No new comments can be posted.

Does launchd Beat cron?

Comments Filter:
  • by NewWazoo ( 2508 ) <bkmatt AT gmail DOT com> on Sunday May 01, 2005 @03:17PM (#12399861) Homepage

    Based on what I've read about it, it's more a replacement for xinetd and the sysv init scripts than cron.

    B
    • Launchd provides faster startup through a unified framework for starting, stopping and managing daemons, and incorporates inetd, init, mach_init, System Starter and related services.
    • by As Seen On TV ( 857673 ) <asseen@gmail.com> on Sunday May 01, 2005 @03:31PM (#12399996)
      The launchd service replaces (takes a deep breath) init, rc, the init.d and rc.d scripts, SystemStarter, inetd and xinetd, atd, crond, and watchdog.

      Basically any task the needs to run on its own, rather than being manually started by a human being, can be handled by launchd.
    • by jamezilla ( 609812 ) on Sunday May 01, 2005 @03:54PM (#12400190) Homepage
      From the launchd.plist man page [apple.com]:
      A daemon or agent launched by launchd SHOULD:
      oo Launch on demand given criteria specified in the XML property list.
      What does cron do? Launch programs! Clearly this means that launchd can be used to replace cron.

      Not only that but looking at the rest of the plist syntax reveals that this thing is waaay cooler than cron. It allows you to set user, group, chroot, check dependencies, designate where to send input and output, set resource limits and whole crapload of other things. Sure you can do this all from within a script, but this thing gives you all that for free.

  • Flexibility (Score:5, Funny)

    by Anonymous Coward on Sunday May 01, 2005 @03:18PM (#12399867)
    But can it be piped?
  • by Anthony Liguori ( 820979 ) on Sunday May 01, 2005 @03:20PM (#12399887) Homepage
    Simply referring to launchd as a cron replacement is a major understatement. launchd runs as the init process and according to TFA was primarily made to replace the /etc/rc.d scripts during startup.

    This is somewhat understandable for something like OS X. Doing something simple like displaying a GUI detailing startup is terribly difficult with /etc/rc.d scripts (considering the length of pause an fsck would take--users would certainly assume there system hung during boot).

    I'm not sure launchd is something you'd want in 99% of Linux installs but if you're looking for a end-to-end user-oriented desktop I can see how a technology like this is necessary.

    I'm not sure Apple Gets It though. Why in the world would they use XML configs? Gesh.
    • by akac ( 571059 ) on Sunday May 01, 2005 @03:23PM (#12399916) Homepage
      Because everything in OS X uses XML configs. A dang site better than Windows Registry or the thousands of permutations that Linux uses.
      • by GamblerZG ( 866389 ) on Sunday May 01, 2005 @03:48PM (#12400131)
        For once I agree. XML is _ideal_ for configs. In fact, it is more suited for configs than for many other fields in which it's actively used. The key things are it's flexibility and human-editability.
        • XML sucks for anything that humans might want to edit: configuration files and documents. It's only barely usable for protocol that, and for that it is rather bloated too. Configuration files should use a simple human-readable format. The .ini format, for example, is rather robust. Of couse, programs that support scripting probably should use the scripting language for configuration so there wont' be a zillion different ways to do things.
          • I agree with parent.
            I've had the misfortune to fiddle with XML config files (tomcat comes to mind). Give me a sane key=value scheme anyday.

          • by NoMaster ( 142776 ) on Sunday May 01, 2005 @08:07PM (#12402493) Homepage Journal
            XML sucks for anything that humans might want to edit
            However, it's pretty damned good for the times where you want a machine to parse your config files and present them in a nice GUI format.

            Which is exactly what Apple - and the average user - wants. Hell, it's also exactly what you want for your X apps, and what you want for those 90% of times when you're configuring non-graphics apps and services through X, a web interface, or even a command-line configuration app.

            The only time it falls down is when editing configuration files manually - and even then, it's still parsable by the human brain.

            Now, I'm no XML fanboy. But honestly, when was the last time you edited anything more than the most trivial .ini or .cfg file by hand? Your MTA? Apache? Samba? BIND? Crontab? Inetd? Initd? IPFW/PF? If you're like me, you did it by hand-editing the first few times so you knew what was going on; since then you've used Webmin or Gnome/KDE's control-panel-like apps.
        • XML is total crap for config files. At least its complexity is somewhat warranted when dealing with document-type data (like HTML or DocBook).

          The problem is that XML's data model is fundamentally broken. Most programming language data structures use records, variants, and lists to organize data and this has worked well for years. XML gives you attributes (which cannot contain nested elements), and sub-elements that are matched accoriding to a regular expression. Stupid, stupid, stupid.

          • If you can't figure out an xml plist config, then you are not smart enough to be in the shell.

            I'd rather deal with "hard" stuff like xml tags than "easy" stuff like switching with screen to the man page over and over again...

            You scared people clearly don't understand plist files and how they represent records and lists.
            plists should be used MORE than just infrequent things like rc/cron... as far as I'm concerned all configs should be plists.

            As for xml being slow...a standard parser may beat a custom par
            • by cakoose ( 460295 ) on Sunday May 01, 2005 @08:25PM (#12402627) Homepage
              If you can't figure out an xml plist config, then you are not smart enough to be in the shell.

              1. It's not about figuring it out. Just because you can figure something out doesn't make it optimal or even non-crap.

              You scared people clearly don't understand plist files and how they represent records and lists.

              2. The grandparent post was talking about XML in general and how it's great for configuration data. That is what I was taking issue with. You can build record/list support on top of XML, but it doesn't fit in naturally.

              3. I still think the property list XML format is crap. Property lists are decent; they're not perfect, but their extreme simplicity makes them very useful. The ASCII format is great, so why would you want an XML format?

              Does having an XML format lets you leverage XML tools? It might have if property list XML worked with XML instead of simply beating it into submission. Apple created a completely opaque layer on top of XML instead of integrating directly.

              {
              Dogs = (
              . {
              . . Name = "Scooby Doo"
              . . Age = 43
              . . Colors = (Brown, Black)
              . }
              )
              }
              A natural XML equivalent would be a little more verbose:
              <Config>
              <Dogs>
              . <Dog>
              . . <Name>Scooby Doo</Name>
              . . <Age>43</Age>
              . . <Colors>
              . . . <Color>Black</Color>
              . . . <Color>Brown</Color>
              . . </Colors>
              . </Dog>
              </Dogs>
              </Config>
              Using Apple's XML format, you'll get:
              <dict>
              <key>Dogs</key>
              <array>
              . <dict>
              . . <key>Name</key>
              . . <string>Scooby Doo</string>
              . . <key>Age</key>
              . . <integer>43</integer>
              . . <key>Colors</key>
              . . <array>
              . . . <string>Brown</string>
              . . . <string>Black</string>
              . . </array>
              . </dict>
              </array>
              </dict>

              The result: something that's more verbose and harder to read than even a natural XML format.

              What's worse is that you can't leverage DTD/Schema as much as you could with a natural XML format.

              • You can't validate semantic structure. (You can ensure that the file is a valid property list XML file, but you can't make sure that it contains launchd configuration info).
              • DTD/Schema sensitive editors still wont help you out with semantic structure. It can auto-complete "key", "dict", etc. but it can't auto complete "Name", "Age", or "Color".
    • by Anonymous Coward on Sunday May 01, 2005 @03:25PM (#12399935)
      No, you don't get it. Why in hell would you want to write yet another config file parser and use your own awkward config format when you could use standard XML and that very same parser that's already loaded to system RAM as a shared lib?
    • by Senjutsu ( 614542 ) on Sunday May 01, 2005 @03:27PM (#12399951)
      I'm not sure Apple Gets It though. Why in the world would they use XML configs?

      To make it easy to edit the files both by hand and via utilities which can be written very easily by leveraging existing XML parsing libraries?
    • by JohnsonWax ( 195390 ) on Sunday May 01, 2005 @03:32PM (#12400004)
      Why in the world would they use XML configs? Gesh.

      Well, machine parsable, heaps of validation tools to make sure you haven't shanked it, and user readable text so you can go in there and hack on it if you want.

      Given that damn near every scripting tool out there has xml support, it seems like they've kept 90% of the admin-friendliness of unix config files and improved on system parsing by simply hanging off of a well proven structured document format, which standard config files most certainly lack.
    • by As Seen On TV ( 857673 ) <asseen@gmail.com> on Sunday May 01, 2005 @03:34PM (#12400018)
      Because XML configuration files are self-validating.

      The fundamental problem launchd was created to solve is system startup time. Twenty or thirty seconds to boot a freakin' laptop is just absurd. So we used launchd to get that down to four.

      But beyond that, launchd also takes care of the problem of having six different types of configuration files, none of which are self-documenting or self-validating. A launchd configuration file can be validated and, if invalid (like somebody inserted a typographical error, or the file got truncated or something), discarded without interfering with system startup. That makes the system more resilient.
      • The fundamental problem launchd was created to solve is system startup time. Twenty or thirty seconds to boot a freakin' laptop is just absurd. So we used launchd to get that down to four.

        You can do parallel startup on most systems these days. Is there any reason why a daemon is necessary to improve startup time? Are shell scripts really that slow?

        But beyond that, launchd also takes care of the problem of having six different types of configuration files, none of which are self-documenting or self-val
        • by As Seen On TV ( 857673 ) <asseen@gmail.com> on Sunday May 01, 2005 @04:15PM (#12400365)
          Is there any reason why a daemon is necessary to improve startup time?

          The launchd service isn't a daemon. It's a replacement for init. And yes, it speeds things up considerably. Previously, every startup script required its own instance of a shell to be fired off. Now that middleman is removed. And it made things considerably faster and simpler.

          But why XML over say something like INI or a much simplier format?

          Because XML is self-validating, like I said. The contents of the file can be checked for consistency before being used for anything.

          It also quickly becomes unreadable.

          You don know that we're talking about property lists here, right? It's an XML-based format, but it's not totally free-form XML. You can't just plug in any valid XML and expect launchd to handle it. If the file doesn't validate against the property list schema, launchd will just ignore it.

          Besides, we've been using property lists everywhere for five years now. Nobody's complained yet. ;-)
          • by crush ( 19364 ) on Sunday May 01, 2005 @06:48PM (#12401768)
            The launchd service isn't a daemon.
            Then why give it a confusingly daemonish name by appending a "d" to the end of it?
            It's a replacement for init.
            Which is a daemon. I can see that a replacement of a daemon might not have to be a daemon, but I'm wondering how that's actually implemented and I'm skeptical of your claim. At the very least you've presented this in a very confusing manner.
          • by JQuick ( 411434 ) on Sunday May 01, 2005 @07:37PM (#12402246)
            The launchd source code is a collection of programs which span several related areas. In the broadest terms the contents of the distribution cover init, SystemStarter, and launchd.

            Most people talking about launchd in the context of parallel system startup are actually talking about SystemStarter. Also note that the plist files which drive SystemStarter can be in one of two forms. The most common of these is the NeXT style textual plist format which is very human friendly and is not XML-like in structure or appearance.

            As a replacement for aither BSD style or System 5 style rc scripts, SystemStarter is a definite improvement, both in terms of ease of use, speed, and reliability. The launchd subsystem uses XML formatted property lists. I am unsure whether NeXT style plists are supported for these.

            Regardless, you were dismissive of launchd claiming that it was mere init replacement. You thought you were speaking about launchd but sound like you had only heard about SystemStarter.

            launchd itself it a super-server which reads process definitions. These definitions can describe processes to be run using a set of predefined keys. Some examples of key value pairs are: Program/ (path to executable), or ProgramArguments/ (The array of strings to pass as arguments to the program). The interesting thing about launchd is that the predefined key/value space is so rich, and so well considered.

            The keys span several related domains which Unix users associate with a number of different tools and data sources. Here are a list of some interesting areas covered.

            like sudo or vixie cron the user and group under which to launch the program can be specified using any of { UserName, UID, GroupName, GID }

            WorkingDirectory causes a chdir(2) before executing the job.
            RootDirectory specieis a chroot(2) for the child process.

            StdOutPath and StdErrPath can specify where to redirect output of the program.

            OnDemand specifies whether to run only as needed or ensure that a server process should always be available, thus respawned.

            Labels and Groups provide a way to refer to processes with greater specificity or to group related processes together for reporting or action using launchctl.

            A set of time specific keywords cover a superset of at and cron time specification.

            Soft and hard resource limits for the job can be tuned using keys that provide acces to all ulimit functionality (file descriptor file size, memory footprint, core size, etc.. Similarly the nice value can be specified to constrain CPU usage, and the *PriorityIO keys specify what priority the kernel should use for scheduling disk IO for this task.

            The Socket Key defines an optional dictionary defining IPC behaviors controlling combinations of open/bind/connect/listen. (think inetd and xinetd). Beyond this you can also specify other things here like "Bonjour" to register this service with mDNSResponder. If a SockPathName is specified attempts to open a named unix domain socket will cause this program to launch.

            If these are not enough, a launchd plist can start/stop a program when a watched file changes. When passed the path to a directory, the program can be started when the program is not running and the directory is not empty. Think about this one... A robust queue processing program might be simply:
            #!/bin/sh
            lockfile $SOMELOCKFILE
            for file in *
            do
            process "$file"
            done

            WorkingDirectory and a watched directory path, along with whatever CPU/Disk IO/Memory/user/group are all handled by launchd. Similarly launchd ensures that the process runs when there is work to do, and is never launched unless there is work to do.

            Finally, if the predefined keys and actions are insufficient you can call a small number of stubs implemented in Tcl to set either one shot timers or interval timers at which point the scripts is re-interpreted. You can pass messages to syslogd, start or stop jobs. A form of system introspection is also pr
      • by gstoddart ( 321705 ) on Sunday May 01, 2005 @03:59PM (#12400223) Homepage
        Because XML configuration files are self-validating.

        As opposed to all of those depressed, self-loathing DOC files out there?
    • I don't know this, but launchd (hopefully) does proper dependency-based concurrency, something that rc.d has lacked for a while. rc.d launches everything in order. What you really need is a dependency graph and then to traverse down it. Init will start first, then anything that directly depends on init. Once a process' dependencies are met, it starts. This is not a hard calculation (though I forget exactly which graph algorithm you use) and could vastly improve startup time. If they're experiencing vastly i
  • by the_2nd_coming ( 444906 ) on Sunday May 01, 2005 @03:20PM (#12399889) Homepage
    the machine boots to a desktop (auto log in and all) in less than 15 seconds.
  • by Anonymous Coward on Sunday May 01, 2005 @03:23PM (#12399919)
    I have nothing to contribute to this discussion, except for my opinion on how ambiguous headlines are. For example, "Does launched beat cron?" has the following possible meanings (yes, I see it's launchd, but listen):
    1) Does as a verb, launchd as n, beat as v, cron as n. That is, a question whether or not the thing "launchd" beats the thing "cron".
    2) Does as a verb, launched as adj, Beat as n, cron as v. That is, a question whether or not thing Beat, which has been launched, crons. (Well, "croon" is a verb, so maybe "cron" is too).
    3) Does as a noun, launched as v, beat as adj, cron as n. That is, a statement that female deer have launched "Beat cron" -- cron that has been beaten, perhaps.
    Any others?
  • by Wesley Felter ( 138342 ) <wesley@felter.org> on Sunday May 01, 2005 @03:24PM (#12399931) Homepage
    Sun came up with (at first glance) a similar thing called Service Management Facility [sun.com] in Solaris 10.
  • Apple is doing a good thing here is shaking up the administrative and setup side of the UNIX world. Most of their work was actually NeXT's, but their "Application as directory" concept is wonderful in a lot of ways, and their reorganizing of the filesystem so that it makes more sense to users is probably a good move in the long run.

    What makes UNIX superior for management and power-users is the ability to do everything you need to from command-line tools and options, and the fact that the storage for configuration is in understandable, alterable files. If those are still there...if I can still run my Apple from the shell--I'm a happy man.

    The only exception to this would be cases where a vendor deliberately makes a deviation simply to introduce incompatibilities. I don't see that as the case here.
  • by Aexia ( 517457 ) on Sunday May 01, 2005 @03:30PM (#12399989)
    that the submitter simply couldn't spell or capitalise correctly?

    "Does launchd Beat cron?"

    What is that? Some new form of AOL speak?
    • by One Childish N00b ( 780549 ) on Sunday May 01, 2005 @03:47PM (#12400125) Homepage
      While confusing, the styling of the article title is correct - it's just the combination of capitalisation as is normal for titles with the names of the commands all being in lower-case. UNIX commands are case-sensitive, thus there is no commad called 'Cron', only 'cron', and it's good journalistic form to spell names for things with correct case, even if (in this example) it does make things a little confusing/AOL-ish
  • Less Compatible? (Score:3, Interesting)

    by imemyself ( 757318 ) on Sunday May 01, 2005 @03:32PM (#12400009)
    Isn't half the attraction to OS X for geeks how its not that much different from Linux or BSD from the console? And that many/most Linux/BSD scripts and apps would work with just a few, if any changes? I don't see how making it more different really helps it. Not trying to be a troll, but I got to assume if all or most the other Unixes work with what launchd replaced just fine, that OS X could as well.
    • by revscat ( 35618 ) on Sunday May 01, 2005 @03:50PM (#12400153) Journal

      Isn't half the attraction to OS X for geeks how its not that much different from Linux or BSD from the console?

      I'm sure some do. But in the aggregate most users will balance something like this against the benefits gained. There are those who are also experimental enough who will try this, and if they find it to be a better implementation will then port it over to other *nix variants, leading to a new "standard".

      rc.d, cron, etc. may be the way other unices do things right now, but that in and of itself is not justification enough to be married to such mechanisms in perpetuity. Sometimes it's beneficial to *cough* you know, "think different."

    • by NMerriam ( 15122 ) <NMerriam@artboy.org> on Sunday May 01, 2005 @05:10PM (#12400826) Homepage
      Isn't half the attraction to OS X for geeks how its not that much different from Linux or BSD from the console?

      For a lot of us, the attraction of OS X is that it is -- finally -- a unix that doesn't suck.

      Apple has done an amazing job in a few short years of replacing the stupid, archaic, and ridiculously fragmented parts of unix that have festered on it like a cancer for decades.

      There are a lot of geeks who are perfectly capable of using unix (and do so on a daily basis) but f*cking hate it because there are 32 separete launch daemons, 47 different configuration file formats, and 376 different GUI permutations, all of which are mutually incompatible except for the token attempts by folks like the LSB, which everyone ignores.

      The truth is that Apple is filling the role now that USC Berkeley filled years ago -- stepping back, evaluating what is there, keeping the good and replacing the bad. Unix had been in dire need of a benevolent dictator for years.
      • by BoydWaters ( 257352 ) on Sunday May 01, 2005 @07:52PM (#12402382)
        > ...USC Berkeley...

        Awesome. One incorrect letter -- the most succinct way of pissing off Northern Californians and Southern Californians I've yet encountered.
      • by drsmithy ( 35869 ) <drsmithy&gmail,com> on Sunday May 01, 2005 @09:50PM (#12403237)
        There are a lot of geeks who are perfectly capable of using unix (and do so on a daily basis) but f*cking hate it because there are 32 separete launch daemons, 47 different configuration file formats, and 376 different GUI permutations, all of which are mutually incompatible except for the token attempts by folks like the LSB, which everyone ignores.

        Damn straight. I love my work as a sysadmin, but I *hate* having to put up with the crap "unix" requires to do a good job. Which is why I don't run it on my desktop.

  • XML? (Score:4, Insightful)

    by Anonymous Coward on Sunday May 01, 2005 @03:49PM (#12400142)
    We do need a replacement for our boot process. Boot GNU/Linux systems is slow. We want processes to be able to start concurrently, or in some cases, with specified pauses. If non-essentials (print server, etc.) start a few seconds after the log-in screen appears, I can be functional faster. We don't have a good system in place now.

    We need a replacement. launchd isn't it. The problem, fundamentally, is XML. XML is a problem since, fundamentally, it is very flexible formatting, and so doesn't play nice with shell scripts. You can't easily cut/sed/etc. xml files. Until we get a suite of replacement tools that can easily modify XML files from shell scripts, XML won't cut it.

    One of the key things to a good system is to make easy, common things fast and easy. The minimal overhead for any program that modifies an XML file is way, way, way to large to want to use it as the standard system format.
    • Re:XML? (Score:3, Insightful)

      by lewiz ( 33370 )
      Not being able to use cut/sed/"etc." is your only reason that launchd is bad?

      Let's put it this way... how long would it take to come up with some simple awk script that will facilitate the use of cut/sed/etc. on XML files? Now, how much longer do you think it would take to address all of issues launchd addresses?
    • Re:XML? (Score:5, Insightful)

      by jonabbey ( 2498 ) * <jonabbey@ganymeta.org> on Sunday May 01, 2005 @05:36PM (#12401061) Homepage

      Python and Perl have perfectly robust XML i/o libraries these days. I don't think I'd mind very much writing the extra ten lines of Python code required to interface with XML, particularly if the transformation I want to do to the config file is simpler in terms of XML than it would be in terms of sed, etc.

    • Apple also includes command line tools such as 'defaults' for editing plists so that you can edit them and make sure that you wind up with a valid plist in the end. There's a new tool in Tiger, but I can't recall

      Perl on OS X also includes the ObjC bridge which can be used to easily read a plist in as a hash. From there it is easy to edit it and then dump it back out.

      So in Mac OS X there are tools to easily read and modify the plists. If porting launchd to another platform, then making comparable tools
  • by rice_burners_suck ( 243660 ) on Sunday May 01, 2005 @03:52PM (#12400168)
    I thought this was a replacement for the big messy SYSV-style init scripts.

    Speaking of which, back in about 1995, I think it was, I installed my first Linux distro that I actually used on a daily basis. It was an early version of SuSE linux. Anyway, as I scratched deeper and deeper under the surface, I came to the conclusion that the init system was a mess... the entire system's functionality was implemented as piles upon piles of shell scripts, organized neatly into a whole bunch of directories, and activated according to their name and whatnot. This seemed kind of dumb, actually, because it meant that startup, shutdown, and switching runmodes were a lot less efficient than necessary, and also because you'd have to search through a zillion (that's a big number) scripts to find what you need.

    A few years later, in 1999 or so, I tried FreeBSD for the first time. (Here it comes, I'm gonna be modded troll for starting another BSD- vs. SYSV-style init script war...) There, the functionality is still implemented in scripts, but there was a much more sane system. There is one script that is the same across all FreeBSD installs of that version. Then, there's the script you get to customize if you want. There's one more file, and that's where you simply give yes or no answers, or provide other data, in the form of environment variables that influence the running of those two scripts. It's so simple, and works quite quickly. Also, since you really only mess with one file, and two if you modify the script, it's much easier to find where things are. It's more efficient, from many standpoints.

    So I don't blame Apple for getting rid of that SYSV stuff. It might have been cool back in the day, but it has lost its luster.

    • by harlows_monkeys ( 106428 ) on Sunday May 01, 2005 @05:16PM (#12400877) Homepage
      A few years later, in 1999 or so, I tried FreeBSD for the first time. (Here it comes, I'm gonna be modded troll for starting another BSD- vs. SYSV-style init script war...) There, the functionality is still implemented in scripts, but there was a much more sane system. There is one script that is the same across all FreeBSD installs of that version. Then, there's the script you get to customize if you want. There's one more file, and that's where you simply give yes or no answers, or provide other data, in the form of environment variables that influence the running of those two scripts. It's so simple, and works quite quickly. Also, since you really only mess with one file, and two if you modify the script, it's much easier to find where things are. It's more efficient, from many standpoints.

      The main problem with that is it presumes that you have a human doing all the messing with that one file.

      The SysV approach is much more friendly to programs, such as installers and uninstallers, and configuration managers, that wish to make changes, or that wish to start and stop individual daemons other than at startup or shutdown.

      • Also, in many cases you don't have to directly edit all those files. For instance, you can chkconfig on many distributions to turn on and off services at boot time. (Or whatever it is Sun uses in Solaris 10 now, not that I've had a chance to play with it much yet.)

        It's also easier to test startup and shutdown scripts. For instance, if I want to test the foo startup script, I just run "/etc/init.d/foo start" (or "service foo start" on some distributions). With the BSD-style startup scripts, I have to add i

  • *sigh* (Score:5, Informative)

    by cbiffle ( 211614 ) on Sunday May 01, 2005 @03:56PM (#12400199)
    This thread, so far, seems to be filled mostly with "Ah! Someone's doing something differently than UNIX has for 30 years! My knee is jerking!" So I feel I should respond.

    launchd is neat. It's not simply a different way of doing the same things, it lets you do different things.

    Like automatically evaluating dependencies between daemons, starting them in the right order, and running them in parallel if needed. FreeBSD's the only other OSS system I've ever seen do this; Gentoo does the dependencies but not the parallel startup. (Which is annoying while it's, say, trying to get an address from a nonexistent DHCP server.) Long story short, it dramatically reduces boot time, while eliminating dependency hacks like runlevels and numbered scripts. (Not that BSD had them.)

    For those of you who posted without reading the manpage (or administering an OSX system), it also lets you do init-style startup tasks on a per-user basis. You can configure it to start daemons and other processes on the behalf of users as the log in, and shut them down -- gracefully, not by TERM; KILL -- when the user logs out.

    Anyone who's ever dealt with the myriad of hacks to get ssh-agent in place will understand why this is good.

    There's a lot of resentment these days toward anyone who does something that's perceived as "not the UNIX way." Change is the only way to innovation, people; perhaps the UNIX way is broader than you thought?
    • Re:*sigh* (Score:5, Informative)

      by enthused i swear ( 641133 ) on Sunday May 01, 2005 @04:21PM (#12400410)
      Gentoo will do parallel startup, though it is not set to by default:

      Modify your /etc/conf.d/rc file thusly:

      # Set to "yes" if you want the rc system to try and start services
      # in parallel for slight speed improvement.

      RC_PARALLEL_STARTUP="yes"
    • by Darren.Moffat ( 24713 ) on Sunday May 01, 2005 @04:42PM (#12400575)
      Solaris 10 has something very similar to launchd called SMF: Service Management Framework. It doesn't replace cron but it does replace init.d and inetd. It also provides backwards compatibility so that existing init.d scripts and run and existing inetd entries are migrated to SMF on upgrade.

      SMF also does dependancy checks and auto matic restart on failure (or some other conditions). It also uses XML for its configuration but imports that into an SQlite database so that it doesn't need to reparse the XML on every service restart or system boot.

      For more information on SMF in Solaris see the links in the main architect/developers blog [sun.com].
  • See also (Score:4, Informative)

    by mattbee ( 17533 ) <matthew@bytemark.co.uk> on Sunday May 01, 2005 @04:39PM (#12400549) Homepage
    daemontools [cr.yp.to] and the free-er clone runit [smarden.org] which both give you the advantages of a non-linear system startup process, automatic service restarting, no need to write daemon-ising code in each program etc. Each author also has common tools to use with these service supervision programs to ensure network-based daemons don't need to write network code: ucspi-tcp [cr.yp.to] and ipsvd [smarden.org] respectively.

    Brave Deian owners can apt-get install runit-run which will start your system with /sbin/runit instead of init from then on; we tend to use it on top of the existing init scripts.

    And the system that's had such a sensible service supervision system since the year dot? Windows NT and its service control manager. Of course you could argue a centrally-controlled daemon restarter is much more of a priority when you expect your daemons to crash more :-)
  • cron still there (Score:5, Informative)

    by Chanc_Gorkon ( 94133 ) <<moc.liamg> <ta> <nokrog>> on Sunday May 01, 2005 @04:39PM (#12400557)
    Ye Olde cron is still there and running. My Bashpodder script still runs on Tiger. As for launchd, I am going to have to read up on that. Sounds interesting.

    Are there schedulers better then cron? You bet. As a scheduler for home use, cron is fine. We are currently trying to find a ore robust replacement for cron that will attempt to correct things before reattempting a script and with dependency checking. When I used to be a operator on a DOS/VSE based mainframe, our scheduler had a dependcy check that would hold jobs from running at thier assigned time if the previous job did not finish and other things like that. It had very robust logging to. No e-mails to root. I could just run a report. There are schedulers that come close to this on UNIX but cron is a very basic scheduler that is flexible which is a saving grace.
  • by DaveGillam ( 880499 ) on Sunday May 01, 2005 @05:16PM (#12400872)
    I'm not an expert, but from what I read of the XML files, launchd seems more of a wrapper program than a replacement for cron. Translated: ProgramArguments = /usr/sbin/cron; QueueDirectories = /var/cron/tabs; ps -wwax|grep cron # shows two cron processes in memory; So launchd takes the place of init, and starts up cron, with the proper arguments. Cron then takes care of its own.
  • by Nelson ( 1275 ) on Sunday May 01, 2005 @05:18PM (#12400889)
    Cron and init and rc.X work fine, I'm not a hater. However I do think it's time to move forward. I like what Sun is doing with SMF and this is Apple's cut at it.

    Basically, cron needs higher resolution, that's my only beef with it. It also seems like to do anything facny with cron you end up writing a program to do it and it's not that uncommon to do that.

    The startup scripts need an all together different kind of overhaul. I've been working on Linux appliances for over 6 years now, without exception, it seems like someone ends up writing some kind of "health script" that is kicked off by cron every minute or a few or is a daemon in it's own right that watches for things to crash or not be running and then it restarts them. I've seen it in a production set-top box based on Linux where we essentially wrote our own init and had it treat some processes special and 5 different software appliances. Fact of life is software crashes from time to time. These scripts then do something else, like ping the gateway or something stupid to check if the network went down before they do what it is that they do. To make matters worse, they are always written in Perl by some guy who doesn't know Bourne shell to write a good startup script in the first place; that's the part that chaps me. Rather than contaminate the system with all this extra shit we should just have an easily extensible and configurable system process starter and monitor and it shouldn't require scripting to do anything advanced.

    • Use XML for configuration, it's easy to parse, it's here to stay and I think it's a little bit better than the columns of a crontab because it's more verbose.
    • Have variable restart behavior, restart, restart and restart dependancies, reboot, just let processes die, etc..
    • Have dependancies (start the database before the shit that inserts data in to it, even though it shouldn't matter, it does) and start them in the right order.
    • Kill dependencies when I kill a process
    • Smart killing, if something doesn't gracefully go down, 9 it down.
    • Have some kind of health monitoring call back, at a time I specify, execute a program that will check to see if a process is okay.
    • Once all this is done, maybe support something like soft cycling, kill everything down to single user mode and then bring it all back.
    • Variable dependency notification, if I restart my database allow me to do nothing to dependant processes, restart them, or HUP them, or something I define.
    • Full featured logging.
    • At some configurable interval, sniff out all of the XML configs in this "next gen startup proc" config directory, like every 5 minutes just check for changes and if needed, start something new up.
    • Allow for user to be specified in the config
    • Allow for end users to have thier own daemons defined by files in their home directories.
    • Then finally, allow for cron like behavior and run tranient tasks with all the flexibility of cron.
    • Proc specific ulimits would be nice also...
    • And some form of runlevel logic still.
    • And startup and kill in parallel if allowed by the depends...
    • And it should have a template for common daemon type things I should just provide a startup command, arguments, a user to run it as, and a run level.

    There are probably some things I forgot, it's really not that much, I could see bangin' this out in Python or java in not that much code. My thinking is that instead of checking for a PID file or grepping through ps outout to provide "status" you query a running process and it tells you your proc is up and running. Yeah yeah, I know, shit shouldn't crash and whatever. I've just seen such a shitty job of this stuff being done over and over and even on fairly stock installs of major linux distributions I've seen service

  • by __aaahtg7394 ( 307602 ) on Sunday May 01, 2005 @05:28PM (#12400983)
    Apple has open sourced the thing, and is apparently hoping all the unix kids will take a look.

    I've been poking around at Apple's Open Source page [apple.com] and fail to see launchd, SystemStartup, or anything else thereabouts. Does anybody have a URL for this, or know of the specifics of getting the source? It looks like promising technology, and I'd love to get my hands on a copy to play with. I would also hate to think that we're being strung along with promises of an Open system that turns out to be only partially open (like the recent KHTML/Safari issue).
  • by metoc ( 224422 ) on Sunday May 01, 2005 @06:47PM (#12401754)
    launchd is also capable of automatically checking for dependencies and scheduling services to startup in the correct order. It can even start services in parallel which speeds up the boot process.
  • by ni5mo ( 590178 ) <alex...j...roberts@@@gmail...com> on Sunday May 01, 2005 @08:41PM (#12402730)
    according to googlefight...

    no! [googlefight.com]

It is easier to write an incorrect program than understand a correct one.

Working...