[Gllug] cron conundrum

Martin A. Brooks martin at clues.ltd.uk
Wed Oct 6 21:48:45 UTC 2004


Richard Jones wrote:

>--- /etc/cron.d/local.pg_dump ----------------------------------------
>MAILTO=rich at annexia.org
>0 2 * * * postgres rm -f /var/tmp/dump.sql.gz
>5 2 * * * postgres pg_dumpall | gzip > /var/tmp/dump.sql.gz
>----------------------------------------------------------------------
>
>As far as I can see, this one doesn't even run.  It certainly doesn't
>update the /var/tmp/dump.sql.gz file ever, and it's never sent me any
>email either. 
>

The first command would (almost) never produce any output, therefore 
you'd never get mail.
The second command will only run if  pg_dumpall lives in the default 
paths used by crond - on my Debian installs it doesn't.  Ypu'll need to 
specify the full path to the command. i.e. 
/usr/lib/postgresql/bin/pg_dumpall  or add /usr/lib/postgresql/bin to 
the paths crond uses.


>The second cronjob is a bit more tricky ...  On the server where I
>want the dist file to end up, I initially put this into my personal
>crontab:
>
>$ crontab -l
>MAILTO=rich at merjis.com
>0 4 * * * scp -q DB.SERVER:/var/tmp/dump.sql.gz /home/rich/saved/
>
>It's a bit stupid, because I realise now that scp running from cron
>won't have access to my ssh-agent / private key, and so won't be able
>to contact the database server.  However, this cronjob has never sent
>me email either, which makes me wonder if it's even running.
>  
>
The "-q" suppresses all but fatal errors.  If the command doesn't 
fatally exit, you won't get a mail because there's no output.

>What's the best way to allow the scp process to contact the server
>securely anyway?
>  
>
Generate a special passphraseless p/p keypair specifically for this 
purpose. Add the public key to the target user at computer's 
authorized_keys file.

Regards

-- 
Martin A. Brooks, Clues Ltd.
http://www.clues.ltd.uk/

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list