chmod() and utime error keep occurring in the site even after the permissions and ownerships are set

I am working on a client site, In the wordpress theme file I have added a cron.php file to perform some cron job functions. It was executing fine without any issues till last few days. When I checked The cron file execution is not happening when I try to execute the file from server I got an error

PHP Fatal error: Uncaught TypeError: ftp_nlist(): Argument #1 ($ftp) must be of type FTPConnection, null given
in wp-admin/includes/class-wp-filesystem-ftpext.php:438

Stack trace:
#0 wp-admin/includes/class-wp-filesystem-ftpext.php(438): ftp_nlist()
#1 wp-admin/includes/class-wp-filesystem-ftpext.php(456): WP_Filesystem_FTPext->exists()
#2 wp-content/plugins/woocommerce/.../File.php:254: WP_Filesystem_FTPext->is_file()
#3 wp-content/plugins/woocommerce/.../File.php:437: File->is_writable()
#4 wp-content/plugins/woocommerce/.../FileController.php:135: File->write()
#5 wp-content/plugins/woocommerce/.../LogHandlerFileV2.php:60: FileController->write_to_file()
#6 wp-content/plugins/woocommerce/includes/class-wc-logger.php:189: LogHandlerFileV2->handle()
#7 wp-content/plugins/woocommerce/includes/class-wc-logger.php:251: WC_Logger->log()
#8 wp-content/plugins/woocommerce/.../FeaturesUtil.php:62: WC_Logger->error()
#9 wp-content/plugins/woocommerce/includes/class-woocommerce.php:836: do_action() → WooCommerce->init()

When I checked for the solutions after going through some multiple sources I found adding define('fs_method', direct) could fix the issue, I have added that and set the ownership and permission through server using this

sudo chown -R www-data:www-data /path/to/wordpress
find /path/to/wordpress -type d -exec chmod 755 {} ;
find /path/to/wordpress -type f -exec chmod 644 {} ;
chmod 775 /path/to/wordpress/wp-content/uploads/wc-logs

For a while the issue seems to be fixed and the cron jobs where done without any problem, after few hours I started getting these warnings on the site

PHP Warning: touch(): Utime failed: Operation not permitted 
in wp-admin/includes/class-wp-filesystem-direct.php on line 529

PHP Warning: chmod(): Operation not permitted 
in wp-admin/includes/class-wp-filesystem-direct.php on line 173

When I set the permissions and ownership again the issue will go for a while but keeps happening after some time. Need a proper fix for the issue gone through multiple forums and blogs and the solution I get is the same.

WooCommerce flagged the error as a bug https://github.com/woocommerce/woocommerce/issues/58985

PHP Fatal error: Uncaught TypeError: ftp_nlist(): Argument #1 ($ftp) must be of type FTPConnection, null givenin wp-admin/includes/class-wp-filesystem-ftpext.php:438

Really needs some help regarding this