I have modified a shell script that was in the fogproject git hub to update all storage nodes.
I can get the shell script to run from an ssh session but not from a cronjob.
does anyone have any suggestions?
#!/bin/bash
export TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
array=( 10fog-helpdesk 11storage 13storage 14storage 15storage 17storage 19storage 21storage 23storage 25storage 27storage 28storage 29storage 30storage 32storage 34storage 36storage 38storage 43storage 44storage )
LOCKFILE=/tmp/synclock.txt
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "already running"
exit
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
clear
echo
echo
echo "Syncing defined systems."
echo
for i in "${array[@]}"
do
printf "FOG Sync Started at: $i..."
successCheck=$(rsync --progress --stats --prune-empty-dirs --delete --bwlimit=500 -avz /images/Sync root@$i:/images/ > /var/log/fog/shopsync.$i.log; rsync --progress --stats --prune-empty-dirs --delete --bwlimit=500 -avz /images/drivers root@$i:/images/ > /var/log/fog/driversync.$i.log;)
if [[ "$successCheck" -eq 0 ]]; then
printf "Success!\n"
else
printf "Failed!\n"
fi
printf "\n"
done
#sleep 1000
rm -f ${LOCKFILE}
I have ssh-copy-id root@10fog-helpdesk to imort my key
I am able too shh root@10fog-helpdesk without a password with no issues.
This is what the cronjob log looks like.
FOG Sync Started at: 10fog-helpdesk...Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
Success!
Any pointers?
Thanks!