If your cronjob does the connection and then take a long time before executing the query is possible that mysql close the connection due to inactivity (connection timeout).
Just check if it is still alive and eventually reconnect.
you can do it with a try catch, something like
try {
//execute the insert
} catch (Exception $e) {
// the insert failed so reconnect and then execute the insert again
}
Eventually in the catch you can check $e->getCode() to verify that the error code is the one of the connection and retry the connection, otherwise throw the exception