WordPress plugin cron working only if admin is logged in

The WP Cron .. which runs when user hit website .. Thus if there are no website visits, WP Cron never runs.

Now you can use 2 solutions.

Disable WP-Cron and use real cron job and then custom real cron job

https://support.hostgator.com/articles/specialized-help/technical/wordpress/how-to-replace-wordpress-cron-with-a-real-cron-job

use custom interval in wp_schedule_event

add_filter( 'cron_schedules', 'myprefix_add_a_cron_schedule' );

function myprefix_add_a_cron_schedule( $schedules ) {

    $schedules['sixsec'] = array(

        'interval' => 21600, // Every 6 hours

        'display'  => __( 'Every 6 hours' ),
    );

    return $schedules;
}

     ///////Schedule an action if it's not already scheduled

if ( ! wp_next_scheduled( 'myprefix_curl_cron_action' ) ) {

    wp_schedule_event( time(), 'sixsec', 'myprefix_curl_cron_action' );
}

///Hook into that action that'll fire sixhour
 add_action( 'myprefix_curl_cron_action', 'import_into_db' );