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
;;