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.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

listing scheduled launchd jobs? (crontab -l)

Howdy,

Is there any simple way to list all the launchd scheduled jobs.

I can imagine awking my way through all the plist files but this is such a basic sysadmin thing I suspect there is something like:

"crontab -l"

lurking around somewhere.

TIA

IJ

MBP 2.2 Ghz, Mac OS X (10.5.2), 2GB Mitsubishi 22" 1600X1050

Posted on Aug 1, 2008 9:55 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 1, 2008 9:58 PM

launchctl list
7 replies

Aug 2, 2008 10:37 PM in response to V.K.

Thanks,

However that's not really an answer to understand what runs when or under what condition.

Crontab -l lists the registered crontab file which is, er, computer-geek-human readable.

launchctl list produces a list of "loaded jobs" in launchd and if they are running the PID but not what it's going to do with them. This is a different capability all together.

It's a start but quite a lot of work to understand what runs under what conditions.

crontab -l
SHELL=/bin/sh
# update 2004-10-30 added cheat sheet, dump lvl7, & mod lvl 5 to weekly
# IGJ CheatSheet Minute Hour DayofMonth Month DayOfWeek
MAILTO=ijeff@sandbox.ca
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin
@daily mbmon -rc1
@weekly /usr/local/bin/cvsup -g -L 2 /usr/local/etc/ports-supfile
@weekly /root/bin/purgeBackup
<snip>
17 3 * * 1-6 /root/bin/myBackup 7
<snip>

launchctl list | grep period
- 0 com.apple.periodic-weekly
- 0 com.apple.periodic-monthly
- 0 com.apple.periodic-daily

Aug 2, 2008 10:52 PM in response to ijeffsc

launchd is CONSIDERABLY more involved than cron and the only way to see what runs when and under which conditions is to look inside the corresponding plist.

launchctl list
will give a list to look at but from there it's one plist at a time. you can quicklook them, open them in Property List editor or some other GUI front. or if you like doing everything from CML you can see the contents of any launch daemon using defaults. for example, run

defaults read /System/Library/LaunchDaemons/com.apple.periodic-daily

and see what's what. Personally, I like [lingon|http://lingon.sourceforge.net> for this.

Aug 10, 2008 3:02 AM in response to V.K.

Thanks,

Yes I've been reading about launchd. The swiss army knife of starty upy things. Very cool but...

What I was hoping for is some little known utility that essentially did a "foreach on a `launchd list`".

So I'll take it that there is no such animal. Too bad it's kind of a fundamental capability to manage scheduled things.

What's interesting is that Launchd itself must "know" so perhaps apple will eventually add that function to launchctl.

begin grumble { plists's are someones over zealous fetish with XML, fine for some things but startup scripts are easier to understand - this will be driving a bunch of non standard hacks to figure out what's happening, sigh, more complexity for less functionality e.g. Windoze Registry vs INI files} end grumble.

Aug 10, 2008 3:19 AM in response to ijeffsc

ijeffsc wrote:
Thanks,

Yes I've been reading about launchd. The swiss army knife of starty upy things. Very cool but...


I think you need to do more reading as it does a lot more than just schedule processes to run at startup.

So I'll take it that there is no such animal. Too bad it's kind of a fundamental capability to manage scheduled things.


As has already been suggested, Lingon is as close as you're going to get to this. launchd is not cron.

begin grumble { plists's are someones over zealous fetish with XML, fine for some things but startup scripts are easier to understand - this will be driving a bunch of non standard hacks to figure out what's happening, sigh, more complexity for less functionality e.g. Windoze Registry vs INI files} end grumble.


Again, I don't think you've paid more than a cursory glance to launchd's feature set, but assuming that I'm wrong: what language would you propose that launchd use to specify job options instead, and how would parsing this language be less complex (and less expensive) than XML? Better yet, how would you propose that jobs requiring elevated permissions be policed for unsafe behavior if the job specification itself contains executable code?

Aug 10, 2008 6:20 AM in response to orangekay

orangekay wrote:
ijeffsc wrote:
Thanks,

Yes I've been reading about launchd. The swiss army knife of starty upy things. Very cool but...


I think you need to do more reading as it does a lot more than just schedule processes to run at startup.

<snip>
Again, I don't think you've paid more than a cursory glance to launchd's feature set, but assuming that I'm wrong: what language would you propose that launchd use to specify job options instead, and how would parsing this language be less complex (and less expensive) than XML? Better yet, how would you propose that jobs requiring elevated permissions be policed for unsafe behavior if the job specification itself contains executable code?


Well that's a decent question that deserves a more thoughtful response.

Launchd is pretty interesting and for a toolset like Launch* I'd be hard pressed suggest a better alternative. That's the answer to Q1. I concede.

However, my badly articulated concern, uttered within my grumble, is that the priorities are kind of screwed up. So we have lost the ability to have simple visibility to one of the most basic and fundamental tools required in enterprise administration. The lowly scheduled job has been obscured somewhere in 80 odd .plist files sprinkled about the system.

The specific question you raise is security related. IMHO security models that work best tend to be very simple. So the traditional Unix solution (without ACL's) is you are very careful about what you choose to run as root. So that's my simple answer to Q2 it's not that important.

Said yet another way. If you did a pareto analysis (or hierarchy of needs) study on all the things that launchd can do, or needs to do, in any serious environment simple management of scheduled jobs would be high on the list. Much higher than the security question you pose. Yet this more important need is not fulfilled and worse the traditional tool has been deprecated.

Ok one more reflection on your last paragraph. You mentioned "expensive". Out of curiosity I start up accounting on most systems that I can on (he said suppressing a Windoze diatribe). You might be surprised to know that on my system LaunchCFMA was the #1 CPU user followed by Safari, Mail, Skype, and WindowServ. On my FreeBSD box (server only) it was Perl, bzip2 procmail and sshd (reflecting the amount of spam processing going on) you had to go back about 30 items to find an OS related gizmo (syslogd).

sa -b | sed -e "s/re//" | sort -n -k2

I was curious.

So in summary Launchd is good but it was created and used to the exclusion of more important simple basic and boring important things, did I mention boring?.

Of course I'm getting kind of old lately and really only favour simple tools like stone wheels, flint axes and fire.

And with that I'll be greping the Plist fantastic for StartInterval and StartCalendarInterfal and adding a zest of sed.

And that sadly is the answer to my question. (ok I admit I will be likely using perl with some xml lib instead but I was trying to keep to the stone axe theme)

IJ

Aug 10, 2008 8:29 AM in response to ijeffsc

ijeffsc wrote:
The specific question you raise is security related. IMHO security models that work best tend to be very simple. So the traditional Unix solution (without ACL's) is you are very careful about what you choose to run as root. So that's my simple answer to Q2 it's not that important.


Said yet another way. If you did a pareto analysis (or hierarchy of needs) study on all the things that launchd can do, or needs to do, in any serious environment simple management of scheduled jobs would be high on the list. Much higher than the security question you pose. Yet this more important need is not fulfilled and worse the traditional tool has been deprecated.


Once again, you are speaking out of pure ignorance as to the role launchd plays in the boot process and in the general day-to-day operations of the OS. I'm curious to know what documentation you're claiming to have read on the subject because the main point of all of it seems to be eluding you completely.

Ok one more reflection on your last paragraph. You mentioned "expensive". Out of curiosity I start up accounting on most systems that I can on (he said suppressing a Windoze diatribe). You might be surprised to know that on my system LaunchCFMA was the #1 CPU user followed by Safari, Mail, Skype, and WindowServ. On my FreeBSD box (server only) it was Perl, bzip2 procmail and sshd (reflecting the amount of spam processing going on) you had to go back about 30 items to find an OS related gizmo (syslogd).

sa -b | sed -e "s/re//" | sort -n -k2

I was curious.

So in summary Launchd is good but it was created and used to the exclusion of more important simple basic and boring important things, did I mention boring?.


How on earth are random sa statistics relevant in any way? The correct answer is that there are few C based XML parsers that will chew up anywhere near as many cycles as a turing complete scripting language's interpreter/VM/runtime would lexing, parsing and executing an arbitrarily complex script. They certainly could have gone for something less verbose like YAML, but they already have the XML parser handy, so why bother?

Also, property lists are not necessarily XML. There are in fact three distinct formats they can be described in, only two of which are human readable. The third is a serialized binary format that is quite compact.

If you ask me, your actual complaint is that you're simply too lazy to learn anything new.

listing scheduled launchd jobs? (crontab -l)

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