|
|
Trouble with launchd
|
|
|
|
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status:
Offline
|
|
I have a bunch of crons that i'm trying to switch over to launchd like a good boy. But so far, it's not working so great. This command works fine from the CLI but not as a launchd. I run with sudo on the CLI, but the launchd is supposed to run as root anyway. It's in /Library/LaunchDeamons
Here's the xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.macfixer.FirewallReset</string>
<key>ProgramArguments</key>
<array>
<string>/sbin/ipfw</string>
<string>delete</string>
<string>set</string>
<string>17</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>1</integer>
</dict>
</dict>
</plist>
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Is there anything being printed to your console? Is it being recognized in your launchctl list?
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status:
Offline
|
|
|
Vandelay Industries
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status:
Offline
|
|
I don't know if there is anything being printed to my console, i'll have to see.
I did use Lingon to create this plist. Doesn't seem to be working though.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status:
Offline
|
|
So I put my firewall command in a script, and had launchd call that script instead of running the command itself, and it worked. Seems odd but oh well, works now.
But I have more launchd questions. Next question is, how do I get a script to run at different times. Like say I wanted something to run at 2am, 4am and 6am, every day. In Cron, i'd just put "2,4,6" as the hour value. But it doesn't look like you can do that with a launchd.
Would I just put in multiple Hour keys? like so:
Code:
<key>Hour</key>
<integer>2</integer>
<key>Hour</key>
<integer>4</integer>
<key>Hour</key>
<integer>6</integer>
Or is there some other way to do it?
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Why are you wanting to do this with launchd anyway?
Cron is still supported, and would be a far more practical way to do this, I think. You could have your cronjob email you when/if your script fails too, and if you'd prefer to invoke your script after certain time intervals rather an absolute times of the day you can use anacron.
Launchd is basically a way to provide the functionality of something like Monit, does not require that developers write an init.d startup script for services, and provides the functionality of anacron. Because your script just runs and then immediately exits you don't need it be constantly monitored, and it doesn't need a script to invoke it. Hence, my question as to why this needs to be done with launchd?
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Mar 2004
Status:
Offline
|
|
Originally Posted by l008com
Next question is, how do I get a script to run at different times. Like say I wanted something to run at 2am, 4am and 6am, every day. In Cron, i'd just put "2,4,6" as the hour value. But it doesn't look like you can do that with a launchd.
Would I just put in multiple Hour keys? like so:
Code:
<key>Hour</key>
<integer>2</integer>
<key>Hour</key>
<integer>4</integer>
<key>Hour</key>
<integer>6</integer>
Or is there some other way to do it?
This should work:
Code:
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>2</integer>
</dict>
<dict>
<key>Hour</key>
<integer>4</integer>
</dict>
<dict>
<key>Hour</key>
<integer>6</integer>
</dict>
</array>
|
-HI-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|