Hi,
Have a script that is supposed to umount /bkup if mounted, fsck /bkup (/dev/da0p1), mount /bkup (/dev/da0p1) and then run multiple rsync commands one at a time. Due to incorrect syntax errors this script is not working as expected.
The idea is to run one command line at a time until it completes. It was my understanding that '&&' means wait until this command is finished before starting next command. But when the script is run, it produces the error "Invalid null command."
The script is run by crontab with /bin/sh /root/scripts/script1.sh and in part is:
#!/bin/sh
/sbin/umount /bkup &&
/sbin/fsck -y /dev/da0p1 &&
/bin/sleep 2 &&
/sbin/mount /bkup &&
/bin/sleep 2 &&
/usr/local/bin/rsync -azP --ignore-existing -e 'ssh -p 19225' root@host1.my-domain.tld:/root /bkup/dir1/ &&
/usr/local/bin/rsync -azP --ignore-existing -e 'ssh -p 19225' root@host2.my-domain.tld:/etc /bkup/dir2/ &&
.
.
.
/bin/sleep 5 &&
/sbin/umount -f /bkup &&
/bin/sleep 2 &&
/sbin/fsck -y /dev/da0p1
There are 26 rsync commands in this script backing up different servers.
Have tried substituting '||' for '&&' on each line but the error is the same.
So the question is, what is the correct syntax to put into the script so that each line must complete BEFORE going to the next command?
Thanks.
Have a script that is supposed to umount /bkup if mounted, fsck /bkup (/dev/da0p1), mount /bkup (/dev/da0p1) and then run multiple rsync commands one at a time. Due to incorrect syntax errors this script is not working as expected.
The idea is to run one command line at a time until it completes. It was my understanding that '&&' means wait until this command is finished before starting next command. But when the script is run, it produces the error "Invalid null command."
The script is run by crontab with /bin/sh /root/scripts/script1.sh and in part is:
#!/bin/sh
/sbin/umount /bkup &&
/sbin/fsck -y /dev/da0p1 &&
/bin/sleep 2 &&
/sbin/mount /bkup &&
/bin/sleep 2 &&
/usr/local/bin/rsync -azP --ignore-existing -e 'ssh -p 19225' root@host1.my-domain.tld:/root /bkup/dir1/ &&
/usr/local/bin/rsync -azP --ignore-existing -e 'ssh -p 19225' root@host2.my-domain.tld:/etc /bkup/dir2/ &&
.
.
.
/bin/sleep 5 &&
/sbin/umount -f /bkup &&
/bin/sleep 2 &&
/sbin/fsck -y /dev/da0p1
There are 26 rsync commands in this script backing up different servers.
Have tried substituting '||' for '&&' on each line but the error is the same.
So the question is, what is the correct syntax to put into the script so that each line must complete BEFORE going to the next command?
Thanks.