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/