Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Before to looking for in the web, i arrive here for help:
Look i have 2 servers running any service, as can be apache, that is running on the port 80, i would like do an script for from the server B, can check the 80 port of the server A, if is running, do:
service httpd stop
If the server B is not listening on the port 80, will start the httpd service
service httpd start
i have this code now:
Code:
if telnet -c 65.254.46.206 80 </dev/null 2>&1 | grep -q Escape; then
echo "Connected"
service httpd stop
else
echo "no connection"
service httpd start
fi
when the server B is not working, working fine, but when is working, take more time, trying, before any minutes do the echo and stop the service, are there any trick or way for reduce the time, by example check by 2 seconds only, if on 2 seconds not respond, do the condition.
If the port is open that means a program/service listens to it
yes sorry, i tested in my V and work okay, but the problem now is that my provider use virtuozzo and when i run my script appear errors ad:
operation not permitted.
i would like thta you can help me do this script using telnet, is possible?
the idea for this script is set a cron for run each 5 minutes, and test if the service if running on the other server, is not runing, start the same service on this server, as this script will run each 5 minutes, for avoid that start again the service, check if the service if runing, if is runing and the service in the other service still down, not should do nothing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.