missing env variables when running from cron

Today I solved another problem that bugged me for a while. Namely, I wanted to run the free flight prediction runs automatically from cron. When I ran it from the commandline or a script, it worked well, but when I tried to run it directly or through the same script from cron, it always failed with the following message : “critical error : basic_string::_S_construct NULL not valid”

I tried everything that came to my mind and that I found on google, but nothing helped.

Normally, the program would log the progress to stdout. But the redirected log or the email contained nothing than the error message. So, the error must have happened during initialization. Consequently, I looked at the source again, and now I spotted a possible problem.

In the program I used getenv(“USER”) and getenv(“HOME”) which I assumed would always be valid. I run the command as root user in cron. If I type echo $HOME or echo $USER at the commandline when logged in as root, it shows the proper values.
But after adding HOME=/root and USER=root to /etc/cron.d/flightpred it works.

So I added fallbacks to the respective places in the code as well.
I still don’t understand, why the env vars were not set when running from cron, but I’m glad it works now.

Btw: You can reach the prediction results at


And today I also added an xml output for use in other applications or apps at :


Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.