get_edit_post_link() not working on wp-cron

Solved by:

//Check and set/unset user to able the script to run as admin
wp_set_current_user(1);
$link = get_edit_post_link($post_to_private->ID);
wp_set_current_user(0);

Thanks Sally CJ,

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)