Now you're including way too much code to wade through. If you reduce the code to just the relevant parts, you'll probably find the error. Nonetheless, tracing it back I
think I may have found it.
10:30:00 - Last user sync at
That seems to imply that at that line,
$last_user_sync is empty or undef. Tracing back where you got that, I see that ulimately the
$ENV{"ORACLE_HOME"} variable is being relied on. Is that set inside your cron job?
As an aside, preview your code. You'll notice that you don't need the <br> at the end of every line, and it makes it much harder to read.
If that doesn't do it, then please cut out all unnecessary crap from your code and repost it. Just a tiny script that does nothing more than fill and print the variable.