Php cron job (wp-cron) not working

admin2025-06-04  1

I try to create a php cron job with help of the WP Control plugin. The purpose is to delete all files in the uploads directory for the current year and month.

I use this code:

$files = glob('./wp-content/uploads/' . date('Y') . '/' . date ('m') . '/*'); // get all file names
foreach($files as $file){ // iterate files
chown ($files, 666); //set the permissions
if(is_file($file)){
  unlink($file); // delete file
}

It is not working. When I set the first line of code:

$files = glob('./wp-content/uploads/' . date('Y') . '/' . date ('m') . '/*'); // get all file names

to

$files = glob('./wp-content/uploads/2019/01/*'); // get all file names`

it works.

What am I missing here?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748990036a315430.html

最新回复(0)