I'm having a really strange problem that only occurs when a server process is launched by cron. The environment is an Ubuntu 12.0.4 LTS distro running in an Azure VM, with an exposed endpoint to the port the server process listens on.
Here's the crontab entry:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/username/ChatScript/LinuxChatScript32 2> /home/username/ChatScript/cronserver.log
Here's how the server process normally works:
- A client opens a TCP connection to the process and sends data immediately
- The server process returns a string and closes the socket
If I run the server process directly from a command line (not launched by cron), everything works fine and I see the response string from the server process. But if cron launches the server process, my test client program can connect fine, send the initial data fine, and the socket closes. But the response string from the server is always empty (0 length). If the server process was "printing" to stdout or some such entity that can be redirected I could understand this. But since it sends its response straight out the socket to the client, I'm baffled. What could cause this kind of behavior?
NOTE: If you're wondering about the 5 minute launch intervals, the server process checks to see if the port it needs is already busy and if so, simply exits. The 5 minute interval schedule serves as a crash/reload mechanism to reload the server process if it goes down.