LINUX-SSH Remote Background Execution script-place background execution issues

Source: Internet
Author: User

Tag: Kill cal load requires Roo quote Ora loop one

Wrote a monitoring load of a smallScript(Dead Cycle,TestKill the corresponding process after the end), because you need to monitor more than one server, so on a single server to useSSHUnifiedExecutionScript

Problems encountered:
using SSH [email protected] '/usr/local/luly/loadavg.sh 2 2 & ' execution
The machine does not immediately exit, occupying SSH connection
The intention is to send commands toRemoteThe machine executes, the native sends after the direct exit

Try:
1, increase nohup, the effect is the same:
SSH [email protected] ' nohup/usr/local/luly/loadavg.sh 2 2 & '

2, increase the network said T,-TT parameters, also no use
ssh-t [email protected] '/usr/local/luly/loadavg.sh 2 2 & '
SSH-TT [email protected] '/usr/local/luly/loadavg.sh 2 2 & '

3, remove the quotation marks, the machine is also inBackstageRun, use SSH connection, must kill the line manually, not what I think
SSH [email protected]/usr/local/luly/loadavg.sh 2 2 &

Final Solution:
Add >/dev/null 2>&1, native Instant exit, no process left, remote background execution script, to achieve the purpose
SSH [email protected] '/usr/local/luly/loadavg.sh 2 2 >/dev/null 2>&1 & '

To monitor the load script:

# cat loadavg.sh#!/bin/Bashusage="Usage: $ second filename"if[$#-ne2 ]; Then echo $USAGE exit1fi>/tmp/monitor/loadavg/146.20_loadavg_$2. Log while[[1=1 ]] DoUptime>>/tmp/monitor/loadavg/146.20_loadavg_$2. Log Sleep $1 Done

LINUX-SSH Remote Background Execution script-place background execution problem (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.