One common issue that I’ve run into while using WordPress is generating a huge number of wp-cron.php and error.log files.

When it gets stuck it will generate these files time and time again until you go and actually debug the issue. Shocking, I know.

In 2 cases the server had 20000+ wp-cron.php files generated. These are small files, it might not affect your space, but it will trigger the max inodes limit on multiple hosting solutions which will make the site inaccessible or slow. Apart from that, it will be almost impossible to navigate the server using cPanel or Filezilla.

This is what happens when I tried to open the folder with 20k+ files in cPanel.

It takes forever to get the files displayed and it eats up all your memory.

I believe Filezilla has a limit of 9999 files and folders that you can see at a time. I wasn’t able to see anything, just a bunch of wp-cron.php files, or navigate properly through the folders.

If you want to start deleting them using the methods above it will require a lot of patience.

But there is a better solution to do this.

How to remove large number of files from WordPress?

Using SSH to delete large number of files.

This will require SSH support from the server and some basic knowledge of using SSH commands. You can find here a list of SSH commands.

  • Connect via SSH using Putty or something similar.
  • Use the pwd command to check where you are on the server.
  • Use cd to navigate to the folder you need to go.
  • List all files inside that folder with ls -a, you will get the full list of file and folders.
  • Once you’re sure of the location you can use the rm filename.extension command to remove file.
  • Since the files will have similar name, you can use a wildcard. In most cases the files are wp-cron.php1, wp-cron.php2 and so on. Using rm wp-cron.php* and it will remove all the files that match that format.

You can also remove the whole folder using rm * foldername.

It will take seconds to complete this task using SSH and it will save you a lot of headaches compared to the other options.

Unfortunately, if your server doesn’t allow SSH connections you might want to contact support to help you with this.