Sponsored Content
Top Forums Shell Programming and Scripting Redirecting Users to New Server Post 302855763 by sanmiogun on Friday 20th of September 2013 07:54:25 PM
Old 09-20-2013
No something simple. The backup server always on no need to reboot. 2 fedora boxes. The backup is an email backup server exactly like d main server. The script should just change IP address on d fly. The main server has a public and local IP. Both servers are connected via local interface. The backup server also have a public ip. The public ip of the backup is configured with a higher priority on d mx records. So external users can access the backup if the main server is down. But for local users pointing to the main server ip there is an issue.
The script running on the backup server should ping d main server public ip and configure the local ip of d backup server to take up d local ip of the main server and release the ip when the main server comes back online when the main server public ip become available.

---------- Post updated 09-21-13 at 12:54 AM ---------- Previous update was 09-20-13 at 11:22 PM ----------

Code:
16.	# add ip / hostname separated by white space 
17.	HOSTS="PublicIP"
18.	 
19.	# no ping request
20.	COUNT=1
21.	 
22.	# email report when 
23.	SUBJECT="Ping failed"
24.	EMAILID="me@mydomain.com"
25.	for myHost in $HOSTS
26.	do
27.	  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
28.	  if [ $count -eq 0 ]; 
29.	
30.	  then
31.	    # 100% failed 
32.	    echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID
33.	    /sbin/ip addr add 155.128.89.55/24 dev eth1
34.	 
35.	  else
36.	    Echo “Host is up and running”
37.	    /sbin/ip addr del 155.128.89.55/24 dev eth1
38.	  fi
39.	Done

will something like this work? I put this together from many sources.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Migrating all users from one linux server to another...

Hello, I've been tasked with migrating users from one linux server to another new linux server. This is how I was thinking of doing it: 1.) Open up an NFS connection between the two servers, cp -Rp /home/ to the new server and then append the old /etc/group & /etc/passwd to the existing... (2 Replies)
Discussion started by: vancouver_joe
2 Replies

2. UNIX for Dummies Questions & Answers

Redirecting output file to a different server.

Hi, I hope this is problem makes sense and that someone can offer some advice. Basically i have a perl script which accesses a database and outputs the information to a file. Is it possible to use a 'system' command to embeb some Unix command which moves that file to another directory... (3 Replies)
Discussion started by: Stormrider
3 Replies

3. UNIX for Dummies Questions & Answers

Users locked out of Server

hiya all, I have Fedora core 3 installed - as a server - onto an old PC. Root u/n and psw lets me in However, all the other accounts no longer worked. They use to work until yesterday... I now get the error at the login screen: "AUTHENTICATIONFAILED" I hope this is a common... (12 Replies)
Discussion started by: marty 600
12 Replies

4. UNIX for Advanced & Expert Users

2 users on the same server (rexec)

Hi, all. Could some one help me please with one problem? In one process (on aix) I should run some remote scripts on other server via rexec. Some scripts should be run on server1 under useridA, and some scripts should be run on the same server under useridB. I specified in .netrc... (10 Replies)
Discussion started by: Anta
10 Replies

5. Red Hat

when users ftp to server the timezone reflected is UTC but the server is set to TZ in localtime

Guys, Need your help coz my server runs in local time GMT +8, but when client use ftp and login, the resulting timestamp seen in each file is in UTC format. We need to set that the time should be the same as GMT +8 when in ftp session. I am using RHEL 5.3. root@]# ll total 1740... (2 Replies)
Discussion started by: shtobias
2 Replies

6. Web Development

Apache - redirecting authenticated users to other sites

Hi everyone. Im really new here, so please have patience with me if i act out of order in any way. I do have some unix experience, but i would not call it extensive. The problem i am about to describe probably have a easy solution, but i have been unable to find it while speaking to Mr.Google... (4 Replies)
Discussion started by: antiw2k3
4 Replies

7. Linux

users can't sftp into my server

I am running a fedora core 13 server and I am having trouble with sftp. My users can connect to the server using SSH both using public key and password authentication. For some reason they are not able to connect using sftp. I'l not sure what's going on. I ran sshd in debug mode and here's... (6 Replies)
Discussion started by: emildiego
6 Replies

8. UNIX for Advanced & Expert Users

Sending Messeges To Users on a Server

I am in the process of doing testing on a backup script that will backup everyones home directories. When I run a "who" I can see the users that are logged on. How can I send these users, let say an instant message other then email to alert them that I am about ready to kick of a test backup? I... (3 Replies)
Discussion started by: metallica1973
3 Replies

9. Red Hat

How to add a new users in proftpd server?

Hi, I have installed proftpd server in my amazon instance and how to enable a new user to access the proftpd. 1. How to add or delete a users 2. how to enable a particular user to access particular folder Regards Paulwintech (5 Replies)
Discussion started by: Paulwintech
5 Replies

10. Shell Programming and Scripting

Ssh fails for one of two users on the same server.

I have two users on dest_host server viz wlsadm & wasadm. From src_host server with root user I m able to passwordless login to wlsadm@dest_host however, the same fails for wasadm@dest_host Below is the debug for both first the working ssh and then the non-working ssh. Works: ... (6 Replies)
Discussion started by: mohtashims
6 Replies
UTMPDUMP(1)							   User Commands						       UTMPDUMP(1)

NAME
utmpdump - dump UTMP and WTMP files in raw format SYNOPSIS
utmpdump [options] [filename] DESCRIPTION
utmpdump is a simple program to dump UTMP and WTMP files in raw format, so they can be examined. utmpdump reads from stdin unless a file- name is passed. OPTIONS
-f, --follow Output appended data as the file grows. -o, --output file Write command output to file instead of standard output. -r, --reverse Undump, write back edited login information into the utmp or wtmp files. -V, --version Display version information and exit. -h, --help Display help text and exit. NOTES
utmpdump can be useful in cases of corrupted utmp or wtmp entries. It can dump out utmp/wtmp to an ASCII file, which can then be edited to remove bogus entries, and reintegrated using: utmpdump -r < ascii_file > wtmp But be warned, utmpdump was written for debugging purposes only. File formats The only binary version of the utmp(5) is standardised. Textual dumps may become incompatible in future. The version 2.28 was the last one that printed text output using ctime(3) timestamp format. Newer dumps use millisecond precision ISO-8601 timestamp format in UTC-0 timezone. Conversion from former timestamp format can be made to binary, although attempt to do so can lead the timestamps to drift amount of timezone offset. BUGS
You may not use the -r option, as the format for the utmp/wtmp files strongly depends on the input format. This tool was not written for normal use, but for debugging only. AUTHOR
Michael Krapp SEE ALSO
last(1), w(1), who(1), utmp(5) AVAILABILITY
The utmpdump command is part of the util-linux package and is available from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils /util-linux/>. util-linux July 2014 UTMPDUMP(1)
All times are GMT -4. The time now is 07:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy