I have two master servers (i.e) myserver1 and myserver2 but one of them is passive and another is primary one which is live in production
I have a script that will tell the status of the machine.
Quote:
unix@myserver1 > cat /tmp/server-status.pl
** Use -h to specify servicename (e.g. myserver.com))
** Use -f to specify status file (e.g. /home/unix/file.txt)
Usage: /tmp/server-status.pl -h servicename -f status_file
E.g. /tmp/server-status.pl -h myserver.com (dns-name) -f /home/unix/file.txt
Returns status (live|passive)
I have a cronjob which pulls the files from the active server in production and the main requirement is to have same cron file on both machines so there is no need to comment if we switch the machines.
Quote:
unix@myserver1 >crontab -l
cd /tmp;if [ `./server-status.pl -h myserver.com -f /home/unix/file.txt` = 'passive' ];then (date;/usr/local/bin/rsync -auzv rsync://myserver1.oracle.com/WWW-primary-master-to-secondary /home/unix ); fi >> /var/log/cron/rsync-log 2>&1
cd /tmp;if [ `./server-status.pl -h myserver.com -f /home/unix/file.txt` = 'passive' ];then (date;/usr/local/bin/rsync -auzv rsync://myserver2.oracle.com/WWW-primary-master-to-secondary /home/unix ); fi >> /var/log/cron/rsync-log 2>&1
unix@myserver2 >crontab -l
cd /tmp;if [ `./server-status.pl -h myserver.com -f /home/unix/file.txt` = 'passive' ];then (date;/usr/local/bin/rsync -auzv rsync://myserver1.oracle.com/WWW-primary-master-to-secondary /home/unix ); fi >> /var/log/cron/rsync-log 2>&1
cd /tmp;if [ `./server-status.pl -h myserver.com -f /home/unix/file.txt` = 'passive' ];then (date;/usr/local/bin/rsync -auzv rsync://myserver2.oracle.com/WWW-primary-master-to-secondary /home/unix ); fi >> /var/log/cron/rsync-log 2>&1
So for eg : if the myserver1 is passive then the two jobs will run on that machine as it meets the criteria, but i want only the job that will run against myserver2 which can pull the files off that machine.
Please assist in having the same crontab on both machines.
Thanks
---------- Post updated 09-11-12 at 11:24 AM ---------- Previous update was 09-10-12 at 04:53 PM ----------
So my question is if myserver2 is passive and not live in production it should only pull the files off myserver1 through rsync but the below jobs in cron pulls the files of myserver1 which is correct and even pull files off myserver2 (pulls files itself on the same server)
Quote:
unix@myserver2 >crontab -l
cd /tmp;if [ `./server-status.pl -h myserver.com -f /home/unix/file.txt` = 'passive' ];then (date;/usr/local/bin/rsync -auzv rsync://myserver1.oracle.com/WWW-primary-master-to-secondary /home/unix ); fi >> /var/log/cron/rsync-log 2>&1
cd /tmp;if [ `./server-status.pl -h myserver.com -f /home/unix/file.txt` = 'passive' ];then (date;/usr/local/bin/rsync -auzv rsync://myserver2.oracle.com/WWW-primary-master-to-secondary /home/unix ); fi >> /var/log/cron/rsync-log 2>&1