Sponsored Content
Full Discussion: Setting a Timeout
Top Forums Shell Programming and Scripting Setting a Timeout Post 302846207 by mathbalaji on Friday 23rd of August 2013 08:23:22 AM
Old 08-23-2013
Setting a Timeout

Hi

I'm writing a script which based on a condition, restarts a set of servers. The problem I'm facing is, say if one of the server is down, my script stops there and fails to proceed. How can I ensure to set a timeout value on that script, so when the server is not reachable, the script should skip that and proceed with the next?

Code:
ssh -o StrictHostKeyChecking=no user1@server1 shutdown -r
ssh -o StrictHostKeyChecking=no user1@server2 shutdown -r
ssh -o StrictHostKeyChecking=no user1@server3 shutdown -r

So, if server 2 is down, my script doesn't restart server 3. Any help?

---------- Post updated at 07:23 AM ---------- Previous update was at 06:18 AM ----------

Found the answer myself!

Looks like I need to add this:

Code:
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 user1@server1 shutdown -r

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Setting Timeout for Xterm Sessions

Hi! Experts, Could someone tell me how to set a time out for xterm users.. I have set TMOUT which logs out telnet users after sometime.. The users here use exceed to connect to Xterm server. So, it doesnt kill xterm windows that have not been used even for 7 days.. Is there any work... (1 Reply)
Discussion started by: jyotipg
1 Replies

2. HP-UX

timeout

How can I kick a user out after being idle for a certain amount of time, would prefer not to use scripts, will TMOUT work on HP-UX? (5 Replies)
Discussion started by: csaunders
5 Replies

3. Solaris

About the Timeout

Hello everyone I am a new one,I want to know how to get the solaris force the loginer out if he do not in a time thanks (4 Replies)
Discussion started by: lyh003473
4 Replies

4. Solaris

Setting Screen Lock Timeout

Hello; I have Solaris 2.6 installed on many Sun AXI Ultra Sparc IIi systems. I want to set the Lock Screen global timeout for all users to 15 minutes. I read the Solaris CDE guide which instructed me to create a /etc/dt/config/C/sys.resources file and changed the timout to 15 minutes in... (1 Reply)
Discussion started by: rambo15
1 Replies

5. AIX

how to change telnet timeout setting

Hi all Can any one solve my problem? I want to change the default timeout setting for telnet in aix, pls help me. (1 Reply)
Discussion started by: vjm
1 Replies

6. Red Hat

RHEL5.5 Socket Timeout Setting

Is there a Linux tunable to reduce the amount of time a socket waits before considering the remote side dead? Its the same senario when you try to telnet to a dead machine, telnet sits and waits for ~30seconds, before the socket timer expires and cancels the request. (5 Replies)
Discussion started by: mrmurdock
5 Replies

7. Shell Programming and Scripting

mpssh - Setting timeout

Hi I am using mpssh client for parallel ssh connections. I need help in setting the timeout for the parallel sessions say 30 seconds. Plz Help. Thanks in advance M.S.Srivatsa Double post, continued here (0 Replies)
Discussion started by: mssrivatsa
0 Replies

8. UNIX for Advanced & Expert Users

mpssh - Setting timeout

Hi I am using mpssh client for parallel ssh connections. I need help in setting the timeout for the parallel sessions say 30 seconds overall. Plz Help. Thanks in advance M.S.Srivatsa (0 Replies)
Discussion started by: mssrivatsa
0 Replies

9. Solaris

Session timeout setting in server

Hi All I need to set timeout of login session of a user if a user is idle for some time. I know the TMOUT setting but it work with only BASH & KORN shell only as I need to set for Bourne shell also. I am trying to put "ClientAliveInterval 300" in sshd_config & restart or refreshing the... (1 Reply)
Discussion started by: sb200
1 Replies

10. Solaris

Is there a difference between setting a user as nologin and setting it as a role?

Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users. In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Discussion started by: os2mac
1 Replies
ssh_connection(3erl)					     Erlang Module Definition					      ssh_connection(3erl)

NAME
ssh_connection - This module provides an API to the ssh connection protocol. DESCRIPTION
This module provides an API to the ssh connection protocol. Not all features of the connection protocol are officially supported yet. Only the ones supported are documented here. COMMON DATA TYPES
Type definitions that are used more than once in this module and/or abstractions to indicate the intended use of the data type: boolean() = true | false string() = list of ASCII characters timeout() = infinity | integer() - in milliseconds. ssh_connection_ref() - opaque to the user returned by ssh:connect/3 or sent to a ssh channel processes ssh_channel_id() = integer() ssh_data_type_code() = 1 ("stderr") | 0 ("normal") are currently valid values see RFC 4254 section 5.2. ssh_request_status() = success | failure MESSAGES SENT TO CHANNEL PROCESSES
As a result of the ssh connection protocol messages on the form {ssh_cm, ssh_connection_ref(), term()} will be sent to a channel process. The term will contain information regarding the ssh connection protocol event, for details see the ssh channel behavior callback han- dle_ssh_msg/2 EXPORTS
adjust_window(ConnectionRef, ChannelId, NumOfBytes) -> ok Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() NumOfBytes = integer() Adjusts the ssh flowcontrol window. Note: This will be taken care of by the ssh_channel behavior when the callback handle_ssh_msg/2 has returned after processing a {ssh_cm, ssh_con- nection_ref(), {data, ssh_channel_id(), ssh_data_type_code(), binary()}} message, and should normally not be called explicitly. close(ConnectionRef, ChannelId) -> ok Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Sends a close message on the channel ChannelId Note: This function will be called by the ssh channel behavior when the channel is terminated see ssh_channel(3erl) and should normally not be called explicitly. exec(ConnectionRef, ChannelId, Command, TimeOut) -> ssh_request_status() Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Command = string() Timeout = timeout() Will request that the server start the execution of the given command, the result will be received as: N X {ssh_cm, ssh_connection_ref(), {data, ssh_channel_id(), ssh_data_type_code(), binary() = Data}} : The result of executing the command may be only one line or thousands of lines depending on the command. 1 X {ssh_cm, ssh_connection_ref(), {eof, ssh_channel_id()}} : Indicates that no more data will be sent. 0 or 1 X {ssh_cm, ssh_connection_ref(), {exit_signal, ssh_channel_id(), string() = ExitSignal, string() = ErrorMsg, string() = LanguageString}} : Not all systems send signals. For details on valid string values see RFC 4254 section 6.10 0 or 1 X {ssh_cm, ssh_connection_ref(), {exit_status, ssh_channel_id(), integer() = ExitStatus}} : It is recommended by the ssh connection protocol that this message shall be sent, but that may not always be the case. 1 X {ssh_cm, ssh_connection_ref(), {closed, ssh_channel_id()}} : Indicates that the ssh channel started for the execution of the command has now been shutdown. These message should be handled by the client. The ssh channel behavior can be used when writing a client. exit_status(ConnectionRef, ChannelId, Status) -> ok Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Status = integer() Sends the exit status of a command to the client. reply_request(ConnectionRef, WantReply, Status, CannelId) -> ok Types ConnectionRef = ssh_connection_ref() WantReply = boolean() Status = ssh_request_status() ChannelId = ssh_channel_id() Sends status replies to requests where the requester has stated that they want a status report e.i . WantReply = true , if WantReply is false calling this function will be a "noop". Should be called after handling an ssh connection protocol message containing a WantReply boolean value. See the ssh_channel behavior callback handle_ssh_msg/2 send(ConnectionRef, ChannelId, Data) -> send(ConnectionRef, ChannelId, Data, Timeout) -> send(ConnectionRef, ChannelId, Type, Data) -> send(ConnectionRef, ChannelId, Type, Data, TimeOut) -> ok | {error, timeout} Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Data = binary() Type = ssh_data_type_code() Timeout = timeout() Sends channel data. send_eof(ConnectionRef, ChannelId) -> ok Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Sends eof on the channel ChannelId . session_channel(ConnectionRef, Timeout) -> session_channel(ConnectionRef, InitialWindowSize, MaxPacketSize, Timeout) -> {ok, ssh_channel_id()} | {error, Reason} Types ConnectionRef = ssh_connection_ref() InitialWindowSize = integer() MaxPacketSize = integer() Timeout = timeout() Reason = term() Opens a channel for a ssh session. A session is a remote execution of a program. The program may be a shell, an application, a sys- tem command, or some built-in subsystem. setenv(ConnectionRef, ChannelId, Var, Value, TimeOut) -> ssh_request_status() Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Var = string() Value = string() Timeout = timeout() Environment variables may be passed to the shell/command to be started later. shell(ConnectionRef, ChannelId) -> ssh_request_status() Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Will request that the user's default shell (typically defined in /etc/passwd in UNIX systems) be started at the other end. subsystem(ConnectionRef, ChannelId, Subsystem, Timeout) -> ssh_request_status() Types ConnectionRef = ssh_connection_ref() ChannelId = ssh_channel_id() Subsystem = string() Timeout = timeout() Sends a request to execute a predefined subsystem. Ericsson AB ssh 2.0.4 ssh_connection(3erl)
All times are GMT -4. The time now is 10:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy