Welcome to MacForumz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

Cron to Launchd migration not working

 
   Macintosh computer (Home) -> System RSS
Related Topics:
slowing down launchd - I'm involved with a project at a private school with around 200 OSX (eMacs and minis) where I'm writing scripts to restore the home folders of each machine on-boot (restore the dock, files, etc). I wrote a BASH..

launchd dnsmasq job - I'm looking to start dnsmasq (dns cache) using a launchd job. It's just a binary (without that can be started manually by executing ' as root. It forks into the when started. Could anyone show me what..

system.log: launchd-problem - Hello, In my there are dozens of entries like Aug 13 15:31:04 desdemona Bug: == How can I find out which daemon is the culprit? Cheers, Michael

cron log - Does anyone know where the cron log is kept on Mac OS X?

Cron on Tiger? - I want to set up some cron jobs. I found that in Tiger, /et/cron is no longer used for system cron jobs ... instead they use Is cron still the way to set up jobs? Or can users use the
Next:  System: USB Broadband Adapter on a MacBook  
Author Message
John Drako

External


Since: Mar 06, 2005
Posts: 87



(Msg. 1) Posted: Wed Feb 27, 2008 10:23 am
Post subject: Cron to Launchd migration not working
Archived from groups: comp>sys>mac>system (more info?)

I have a Mac Mini whose job is to back up various online sites.

When it was running Tiger, it ran various scripts launched by cron to do
the job. Nobody would be logged into the system and the scripts would
fire at their assigned times.

After 10.5.2 came out, I upgraded the system to Leopard and a day later
realized that non of the scripts worked the previous night.

So I used lingon to create launchd files. Restarted the system and the
next day still nothing.

I can run the scripts from the terminal and they would work normally.

Here is what the scripts contain:

#!/bin/bash
cd /Users/john/database
ssh root RemoveThis @mydomain.com "mysqldump xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
scp -l 1000 root RemoveThis @mydomain.com:database.sql.bz2 .

The xxxxx sequence is the variables for mysqldump. The ssh
authentication is done via certificates. In the terminal a simple

../dbbackup.sh

gets the database backed up and it worked with cron when nobody was
logged in.

I want those events to trigger when nobody is logged into the system.

I checked the console log and the error reported is:

Host key verification failed

So obviously, ssh authentication is not working. It worked when cron
launched the script.

What do I need to change to get it to work when started with Launchd?

Thanks in advance.

 >> Stay informed about: Cron to Launchd migration not working 
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1708



(Msg. 2) Posted: Wed Feb 27, 2008 10:26 am
Post subject: Re: Cron to Launchd migration not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <fq3v8l0oh0.DeleteThis@news5.newsguy.com>,
John Drako <jbravo556.DeleteThis@gmail.removethis.com> wrote:

> I have a Mac Mini whose job is to back up various online sites.
>
> When it was running Tiger, it ran various scripts launched by cron to do
> the job. Nobody would be logged into the system and the scripts would
> fire at their assigned times.
>
> After 10.5.2 came out, I upgraded the system to Leopard and a day later
> realized that non of the scripts worked the previous night.
>
> So I used lingon to create launchd files. Restarted the system and the
> next day still nothing.

Where'd you put the file? Different locations can produce different
results.

> I can run the scripts from the terminal and they would work normally.
>
> Here is what the scripts contain:
>
> #!/bin/bash
> cd /Users/john/database
> ssh root.DeleteThis@mydomain.com "mysqldump xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> scp -l 1000 root.DeleteThis@mydomain.com:database.sql.bz2 .
>
> The xxxxx sequence is the variables for mysqldump. The ssh
> authentication is done via certificates. In the terminal a simple
>
> ./dbbackup.sh
>
> gets the database backed up and it worked with cron when nobody was
> logged in.

Based on that, you're probably relying on SSH keys in your account.

> I want those events to trigger when nobody is logged into the system.
>
> I checked the console log and the error reported is:
>
> Host key verification failed
>
> So obviously, ssh authentication is not working. It worked when cron
> launched the script.
>
> What do I need to change to get it to work when started with Launchd?

Was this job previously using the system-wide crontab, or your account's
crontab?

It sounds like SSH isn't finding the keys it needs to connect, which
probably means it's not running as the right user. If you previously
ran this job from your personal account, it would look there for SSH
keys, but launchd may be running as root (depending on where you
installed this launchd plist).

You probably need to add a UserName field to the launchd plist, set to
your own account. That'll make launchd run as you rather than root, and
it should pick up your account's SSH keys.

--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/

 >> Stay informed about: Cron to Launchd migration not working 
Back to top
Login to vote
John Drako

External


Since: Mar 06, 2005
Posts: 87



(Msg. 3) Posted: Wed Feb 27, 2008 1:49 pm
Post subject: Re: Cron to Launchd migration not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 27 Feb 2008 12:26:08 -0500, Tom Harrington wrote
(in article <tph-CE27B3.10260727022008@localhost>):

> You probably need to add a UserName field to the launchd plist, set to
> your own account. That'll make launchd run as you rather than root, and
> it should pick up your account's SSH keys.


All right, I added the UserName key to the .plist file. We'll see
tomorrow morning if everything went well during the night. Can't run
those scripts while the servers are busy.

Thanks for the tips.
 >> Stay informed about: Cron to Launchd migration not working 
Back to top
Login to vote
user638

External


Since: Jan 13, 2005
Posts: 916



(Msg. 4) Posted: Thu Feb 28, 2008 2:00 am
Post subject: Re: Cron to Launchd migration not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <fq3v8l0oh0.TakeThisOut@news5.newsguy.com>,
John Drako <jbravo556.TakeThisOut@gmail.removethis.com> wrote:

> I have a Mac Mini whose job is to back up various online sites.
>
> When it was running Tiger, it ran various scripts launched by cron to do
> the job. Nobody would be logged into the system and the scripts would
> fire at their assigned times.
>
> After 10.5.2 came out, I upgraded the system to Leopard and a day later
> realized that non of the scripts worked the previous night.
>
> So I used lingon to create launchd files. Restarted the system and the
> next day still nothing.
>
> I can run the scripts from the terminal and they would work normally.
>
> Here is what the scripts contain:
>
> #!/bin/bash
> cd /Users/john/database
> ssh root.TakeThisOut@mydomain.com "mysqldump xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> scp -l 1000 root.TakeThisOut@mydomain.com:database.sql.bz2 .
>
> The xxxxx sequence is the variables for mysqldump. The ssh
> authentication is done via certificates. In the terminal a simple
>
> ./dbbackup.sh
>
> gets the database backed up and it worked with cron when nobody was
> logged in.
>
> I want those events to trigger when nobody is logged into the system.
>
> I checked the console log and the error reported is:
>
> Host key verification failed
>
> So obviously, ssh authentication is not working. It worked when cron
> launched the script.
>
> What do I need to change to get it to work when started with Launchd?
>
> Thanks in advance.

FYI: I'm using cron on a Mac OS X 10.5.2 iBook which starts
rsnapshot backups for my Mom's iMac, my Wife's iBook, and my
Mother-in-Law's iBook (aka perl script running rsync over ssh)

cron has been working as expected.

Bob Harris
 >> Stay informed about: Cron to Launchd migration not working 
Back to top
Login to vote
John Drako

External


Since: Mar 06, 2005
Posts: 87



(Msg. 5) Posted: Thu Feb 28, 2008 10:09 am
Post subject: Re: Cron to Launchd migration not working <= Solved [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 27 Feb 2008 13:49:04 -0500, John Drako wrote
(in article <fq4bb0015tl.DeleteThis@news5.newsguy.com>):

> On Wed, 27 Feb 2008 12:26:08 -0500, Tom Harrington wrote
> (in article <tph-CE27B3.10260727022008@localhost>):
>
>> You probably need to add a UserName field to the launchd plist, set to
>> your own account. That'll make launchd run as you rather than root, and
>> it should pick up your account's SSH keys.
>
>
> All right, I added the UserName key to the .plist file. We'll see
> tomorrow morning if everything went well during the night. Can't run
> those scripts while the servers are busy.
>
> Thanks for the tips.

Yep, the 'UserName' key addition to the .plist file worked. The scripts
executed at the correct time and the ssh session happened when nobody
was logged into the system.
 >> Stay informed about: Cron to Launchd migration not working 
Back to top
Login to vote
Display posts from previous:   
   Macintosh computer (Home) -> System All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]