1

I have a script to start and fork a netcat process. After a while, the netcat process stops logging output. Remote computers are supposed to connect to the socket and send a message every few hours, but it seems like the netcat process dies/halts after a while, because there's usually only one message from the remotes on the hour after the daemon starts, and then no more follow. I ensured it wasn't a problem with the remotes not sending their information to the socket; so it seems like something to do with the netcat process dying out. When I run atop, the process is still alive, but if I try to connect to the socket manually and send something, it doesn't log it to the output file.

dstart(){
    if [ -f /run/mynetcat.pid ]; then
      echo "Netcat instance running on "$(cat /run/mynetcat.pid)
      exit 1
    else 
      echo "Starting Netcat instance"
      mkdir -p /var/log/mynetcat/
      (setsid nc -l -k -p 25001 >> /var/log/mynetcat/mynetcat.log 2> /var/log/mynetcat/mynetcat.err & echo $! > /run/mynetcat.pid)&
      return 0
    fi
}
###later on in the script

case "$1" in
  start)
      dstart
      ;;
Connor
  • 11
  • 2
  • Use "netstat -a" to check open connections. I suspect that the problem is that the remotes are not terminating their connections. – Stephen C Jan 26 '18 at 02:03
  • I've edited the remote scripts to close and reopen the socket as necessary. Will report back here if that works or not. – Connor Jan 26 '18 at 21:51

0 Answers0