I'm debugging a C program running on a remote server. This program saves ~3MB data files to a directory and prints strings to the terminal every 10 seconds with an infinite loop. If I ssh into the server and run the program, the output message and data look reasonable. However, when I put the program in crontab and reboot, then the program runs in background but it stops creating data files in several minutes. Cron seems to run the program sucessfully. When I open htop, the program is there. But strangely I don't get any output from the program. Unfortunately, the cron log file is also not updated anymore from the moment.
How could I monitor the C program in background? Is it possible to look at the stdout, stderr of a background process in real time? Or, Would there be a popular approach to debugging such program?