scp does not work with cron jobs
Hi,
I have written a shall script which creates a tar file and scp to remote machine. It is working fine if i run this script manualy (./backup_agent.sh) but if i execute this using cron jobs it does every thing othre then scp part of it . file name is backup_agent.sh ---------------------------------------- #!/bin/sh cd /var/BACKUP tar -cvf cvsroot.tar /var/cvsroot #tar -cvf cvsroot.tar cvsbackup.txt gzip cvsroot.tar /usr/bin/scp cvsroot.tar.gz root@192.168.1.100:/BEGANTO_BACKUP/cvs/cvsroot-$(date +%Y%m%d-%H%M%S).tar.gz echo "Backup of cvsroot has been copied in form of .tar.gz file" mv cvsroot.tar.gz cvsroot-$(date +%Y%m%d-%H%M%S).tar.gz mail -s "CVS server backup" yogendra.rawat@beganto.com < cvsbackup.txt Please help. Thanks Yogendra Rawat |
do you have to enter a password to connect to the other machine? which user runs the cronjob? which user runs the script manually?
Greetings, Benjamin |
This will allow your server not to authenticate in the backup server:
Do this in the machine that has your cronjob mkdir –p /root/.ssh chmod 0700 /root/.ssh ssh-keygen –t dsa –f /root/.ssh/id_dsa –P '' then copy /root/.ssh/id_dsa.pub to the backup server then do this in your backup server cat id_dsa.pub >> /root/.ssh/authorized_keys2 chmod 0600 /root/.ssh/ authorized_keys2 |
All times are GMT -5. The time now is 09:56 AM. |