Wp Maintenance mode and external cron job

You can use the wp_doing_cron() method to determine if the request comes from a cron request or not.

if(
    defined( 'IN_MAINTENANCE' )
    && IN_MAINTENANCE
    && $pagenow !== 'wp-login.php'
    && ! is_user_logged_in()
    && ! wp_doing_cron()
) {

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