0

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?

0

Not sure if I understand correctly what you want, but you can redirect stderr and stdout to separate files : ./myprogram 2>./stderr 1>./stdout or to the same file : ./myprogram > ./logfile 2>&1

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.