Motherboard Forums


Reply
Thread Tools Display Modes

What would I use to create a plist (for launched) from the command line?

 
 
paris2venice@gmail.com
Guest
Posts: n/a
 
      05-25-2012, 01:45 AM
I've looked at PlistBuddy, defaults and plutil and I've done quite a bit ofgoogling but cannot come up with a method to easily create a plist for a script to run in launchd as I would have previously done with cron. I thought the natural progression was for stuff to get easier (esp. with Apple) but it appears that chaos theory is wrong after all.
 
Reply With Quote
 
 
 
 
JF Mezei
Guest
Posts: n/a
 
      05-25-2012, 02:58 AM
(E-Mail Removed) wrote:
> I've looked at PlistBuddy, defaults and plutil and I've done quite a bit of googling but cannot come up with a method to easily create a plist for a script to run in launchd as I would have previously done with cron. I thought the natural progression was for stuff to get easier (esp. with Apple) but it appears that chaos theory is wrong after all.



man launchd.plist

This documents all the keys/values you can/should put in the launchd
plist file.

There are also some utilities that will edit/create the plists for you.
But the names escape me at the moment.

You can inspire yourself of existing plists as well.

Once the plist has been created and placed in the launchd daemons
folder, you can use launchdctl command to load that plist and start the
system. Once this is done, the rest is handled by launchd, including
restarting the job if it fails, throttling restarts if it fails too
often etc.
 
Reply With Quote
 
 
 
 
Alan Baker
Guest
Posts: n/a
 
      05-25-2012, 03:03 AM
In article <4fbef562$0$31122$c3e8da3$(E-Mail Removed) om>,
JF Mezei <(E-Mail Removed)> wrote:

> (E-Mail Removed) wrote:
> > I've looked at PlistBuddy, defaults and plutil and I've done quite a bit of
> > googling but cannot come up with a method to easily create a plist for a
> > script to run in launchd as I would have previously done with cron. I
> > thought the natural progression was for stuff to get easier (esp. with
> > Apple) but it appears that chaos theory is wrong after all.

>
>
> man launchd.plist
>
> This documents all the keys/values you can/should put in the launchd
> plist file.
>
> There are also some utilities that will edit/create the plists for you.
> But the names escape me at the moment.


Lingon.

>
> You can inspire yourself of existing plists as well.
>
> Once the plist has been created and placed in the launchd daemons
> folder, you can use launchdctl command to load that plist and start the
> system. Once this is done, the rest is handled by launchd, including
> restarting the job if it fails, throttling restarts if it fails too
> often etc.


--
Alan Baker
Vancouver, British Columbia
"If you raise the ceiling four feet, move the fireplace from that wall
to that wall, you'll still only get the full stereophonic effect if you
sit in the bottom of that cupboard."
 
Reply With Quote
 
Michael Vilain
Guest
Posts: n/a
 
      05-25-2012, 03:23 AM
In article <(E-Mail Removed)>,
(E-Mail Removed) wrote:

> I've looked at PlistBuddy, defaults and plutil and I've done quite a bit of
> googling but cannot come up with a method to easily create a plist for a
> script to run in launchd as I would have previously done with cron. I
> thought the natural progression was for stuff to get easier (esp. with Apple)
> but it appears that chaos theory is wrong after all.


To create it from a command-line, first off it's a multi-line file with
multiple parameters. I looked at moving my cron job to launchd and
found launchd on 10.6.8 couldn't do what I wanted with cron (run Mail if
and only if it's not already running, run every 15 minutes).

If I had to create a .plist file, I'd used perl. There may even be a
CPAN module for it. If not, you'll have to familarize yourself with the
grammar of the files by reading Apple's docs on launchd, then write code
to generate the file. I read through Apple's docs on launchd. They're
not very well written or are just overly pedantic.

In any case, you've got some reading to do.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]


 
Reply With Quote
 
JF Mezei
Guest
Posts: n/a
 
      05-25-2012, 03:50 AM
Alan Baker wrote:

> Lingon.


Yep, that's the one. It will create a fairly standard plist for launchd.

You can then use the Property List Editor which should be in yoru
utilities folder (or perhaps only comes with the development kit, not
sure) to fine tune it.

No need to edit the raw xml.

 
Reply With Quote
 
Paul Sture
Guest
Posts: n/a
 
      05-25-2012, 07:30 AM
On Thu, 24 May 2012 20:23:05 -0700, Michael Vilain wrote:

> In article <(E-Mail Removed)>,
> (E-Mail Removed) wrote:
>
>> I've looked at PlistBuddy, defaults and plutil and I've done quite a
>> bit of googling but cannot come up with a method to easily create a
>> plist for a script to run in launchd as I would have previously done
>> with cron. I thought the natural progression was for stuff to get
>> easier (esp. with Apple) but it appears that chaos theory is wrong
>> after all.

>
> To create it from a command-line, first off it's a multi-line file with
> multiple parameters. I looked at moving my cron job to launchd and
> found launchd on 10.6.8 couldn't do what I wanted with cron (run Mail if
> and only if it's not already running, run every 15 minutes).


I tried that when plists first came along. The only way I could find to
do it was put a whole load of entries in for 8:00, 8:15. 8:30 etc.

The cron equivalent that gets you that for 24 hours a day is of the form:

*/15 * * * * /usr/sbin/fetchnews 1>/dev/null

> If I had to create a .plist file, I'd used perl. There may even be a
> CPAN module for it. If not, you'll have to familarize yourself with the
> grammar of the files by reading Apple's docs on launchd, then write code
> to generate the file. I read through Apple's docs on launchd. They're
> not very well written or are just overly pedantic.
>
> In any case, you've got some reading to do.


Agreed. The launchd mechanism is great for certain things, such as
triggering an action when a file lands in a directory, but as a simple
replacement for cron, it is overcomplicated.



--
Paul Sture
 
Reply With Quote
 
David Empson
Guest
Posts: n/a
 
      05-25-2012, 07:59 AM
JF Mezei <(E-Mail Removed)> wrote:

> Alan Baker wrote:
>
> > Lingon.

>
> Yep, that's the one. It will create a fairly standard plist for launchd.


Lingon version 1 was open source, available at

http://sourceforge.net/projects/lingon/

Lingon versions 2 and 3 are being sold via App Store (therefore only
available for Snow Leopard and later). Version 2 has improvements over
version 1, and didn't lose any functionality. (I have this version.)

As far as I can see, Version 3 is a major rewrite to comply with App
Store rules, so it can't do anything which needs authentication. That
means it can't directly work on launchd plists in the /System and
/Library folders, only the user's own ~/Library/LaunchAgents folder (or
other arbitrary locations which don't require authentication).

> You can then use the Property List Editor which should be in yoru
> utilities folder (or perhaps only comes with the development kit, not
> sure) to fine tune it.


Property List Editor is installed with the developer tools up to Xcode
3.x (not sure whether it was also there for early versions of Xcode 4).

With Xcode 4.3 (in Lion), Property List Editor it is no longer available
as a standalone utility, and its functionality is built into the Xcode
application.

--
David Empson
(E-Mail Removed)
 
Reply With Quote
 
Paul Sture
Guest
Posts: n/a
 
      05-25-2012, 08:43 AM
On Fri, 25 May 2012 09:30:56 +0200, Paul Sture wrote:

> tried that when plists first came along. The only way I could find to
> do it was put a whole load of entries in for 8:00, 8:15. 8:30 etc.
>
> The cron equivalent that gets you that for 24 hours a day is of the
> form:
>
> */15 * * * * /usr/sbin/fetchnews 1>/dev/null


And to be pedantic, that entry is something I copied off the internets.
The real working thing looks like this:

*/15 * * * * news /usr/sbin/fetchnews 1>/dev/null



--
Paul Sture
 
Reply With Quote
 
Barry Margolin
Guest
Posts: n/a
 
      05-25-2012, 03:15 PM
In article <(E-Mail Removed)>,
Paul Sture <(E-Mail Removed)> wrote:

> On Fri, 25 May 2012 09:30:56 +0200, Paul Sture wrote:
>
> > tried that when plists first came along. The only way I could find to
> > do it was put a whole load of entries in for 8:00, 8:15. 8:30 etc.
> >
> > The cron equivalent that gets you that for 24 hours a day is of the
> > form:
> >
> > */15 * * * * /usr/sbin/fetchnews 1>/dev/null

>
> And to be pedantic, that entry is something I copied off the internets.
> The real working thing looks like this:
>
> */15 * * * * news /usr/sbin/fetchnews 1>/dev/null


You only put the username in the file if it's the system-wide
/etc/crontab. But normally, cron jobs are installed using the "crontab"
command, which puts them in per-user files in /usr/lib/cron/jobs. These
files don't contain the username after the time fields, since it would
be redundant.

--
Barry Margolin, (E-Mail Removed)
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
 
paris2venice@gmail.com
Guest
Posts: n/a
 
      05-25-2012, 08:26 PM
On Friday, May 25, 2012 12:30:56 AM UTC-7, Paul Sture wrote:
> On Thu, 24 May 2012 20:23:05 -0700, Michael Vilain wrote:
>
> > In article <(E-Mail Removed)>,
> > (E-Mail Removed) wrote:
> >
> >> I've looked at PlistBuddy, defaults and plutil and I've done quite a
> >> bit of googling but cannot come up with a method to easily create a
> >> plist for a script to run in launchd as I would have previously done
> >> with cron. I thought the natural progression was for stuff to get
> >> easier (esp. with Apple) but it appears that chaos theory is wrong
> >> after all.

> >
> > To create it from a command-line, first off it's a multi-line file with
> > multiple parameters. I looked at moving my cron job to launchd and
> > found launchd on 10.6.8 couldn't do what I wanted with cron (run Mail if
> > and only if it's not already running, run every 15 minutes).

>
> I tried that when plists first came along. The only way I could find to
> do it was put a whole load of entries in for 8:00, 8:15. 8:30 etc.
>
> The cron equivalent that gets you that for 24 hours a day is of the form:
>
> */15 * * * * /usr/sbin/fetchnews 1>/dev/null
>
> > If I had to create a .plist file, I'd used perl. There may even be a
> > CPAN module for it. If not, you'll have to familarize yourself with the
> > grammar of the files by reading Apple's docs on launchd, then write code
> > to generate the file. I read through Apple's docs on launchd. They're
> > not very well written or are just overly pedantic.
> >
> > In any case, you've got some reading to do.

>
> Agreed. The launchd mechanism is great for certain things, such as
> triggering an action when a file lands in a directory, but as a simple
> replacement for cron, it is overcomplicated.



So you would recommend just sticking with cron? I've written probably at least a hundred cron jobs over the last 25 years so I'd prefer that. I guess I reacted only because I saw cron being labeled by Apple as 'obsolete'.

p.s. Sorry for the misspell of launchd -- Safari's spell checker did it. And my humor about chaos theory doesn't even make sense now that I re-read it. Lame, I guess.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing com.apple.LaunchServices.plist AJ Apple 0 07-12-2004 04:11 PM
Identifying plist files Stan The Man Apple 1 04-10-2004 05:15 PM
how hard would it be to create a external hard drive enclosure? Michael Embedded 8 09-22-2003 03:26 PM
com.apple.finder.plist trashed John B. Matthews Apple 0 08-08-2003 03:49 PM
Console log about broken plist - how to get rid of Jussi Piitulainen Apple 0 07-08-2003 07:54 PM


All times are GMT. The time now is 03:55 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment