hello,
I have a couple of longish commands that I run to backup my network of xen hosts. I would like to cron this, but am having trouble issuing the same command the second time to the second xen host:
[root@LCENT01 ~]# ssh sum2 'for i in `virsh list | grep -v -e Id -e --- -e "Domain-0"| awk '{print $1}'`; do echo "shutting down $i"; sleep 2; virsh shutdown $i; sleep 2; echo "domain $i is shutdown"; echo echo; done' root@sum2's password: awk: cmd. line:1: {print awk: cmd. line:1: ^ unexpected newline or end of string
------
this is the script so far:
#!/bin/bash
for i in `virsh list | grep -v -e Id -e --- -e "Domain-0"| awk '{print $1}'`; do echo "shutting down $i"; sleep 2; virsh shutdown $i; sleep 2; echo "domain $i is shutdown"; echo; echo; \
for i in *; do echo "copying $i to nas"; sleep 2; rsync -avzp /mnt/store/xen/$i /mnt/nas/xen; sleep 2; echo "$i has been copied to nas"; echo; echo; done
ssh sum2 'for i in `virsh list | grep -v -e Id -e --- -e "Domain-0"| awk '{print $1}'`; do echo "shutting down $i"; sleep 2; virsh shutdown $i; sleep 2; echo "domain $i is shutdown"; echo echo; done'
I think this could actually pretty useful for folks. feel free to use and improve I would appreciate the feedback to get this to work so I don't have to run two separate jobs on separate hosts
thanks!!!