bash 스크립트에서 memcached 인스턴스를 플러시해야합니다. 작업을 수행하는 다음 명령을 찾았습니다.
echo 'flush_all' | ncat localhost 11211
그러나 내 문제는 스크립트가 다음 명령을 계속하지 않고 ncat
의 응답으로 중지된다는 것입니다 .
콘솔에서 수동으로 명령을 보내면 CTRL+C
프로세스 를 종료해야합니다 .
나는 그것이 정상적인 행동 echo
이나 ncat
명령 이라고 생각 하지만 그것을 우회하는 것을 모른다 … 당신은 그것을 해결하는 방법을 알고 있습니까?
답변
의 타이밍 옵션 중 일부를 사용해 보셨습니까 ncat
? 에서 발췌 한 관련 이벤트는 다음과 같습니다 man ncat(1)
.
타이밍 옵션
These options accept a time parameter. This is specified in seconds by default, though you can append ms, s, m, or h to the value to specify milliseconds, seconds, minutes, or hours. -d time, --delay time (Specify line delay) . Set the delay interval for lines sent. This effectively limits the number of lines that Ncat will send in the specified period. This may be useful for low-bandwidth sites, or have other uses such as coping with annoying iptables --limit options. -i time, --idle-timeout time (Specify idle timeout) . Set a fixed timeout for idle connections. If the idle timeout is reached, the connection is terminated. -w time, --wait time (Specify connect timeout) . Set a fixed timeout for connection attempts.
따라서 당신의 상황에서 당신은 실행할 것 echo 'flush_all' | ncat -i 10s localhost 11211
입니다.