filedir Clean up in Windows

filedir Clean up in Windows

by Ryan Carpenter -
Number of replies: 2

I'm using Moodle 3.3 to develop and test SCORM files on my local Windows machine. I only ever have a few videos and ten SCORM activities installed, but my moodledata/filedir directory is full of hundreds of large files (> 100MB each). I assume that these are remnants of previous versions of the SCORM activities that should have been automatically cleaned up (but weren't).

From this page, I installed MoodleCron-Setup.exe, but that hasn't made any difference that I can see. I don't see a cron.log file anywhere. I tried executing via CLI, but got the error below.

PS C:\MoodleWindowsInstaller-latest-33\server\moodle\admin> C:\MoodleWindowsInstaller-latest-33\server\php\php.exe -f C:\MoodleWindowsInstaller-latest-33\serv
er\moodle\admin\cli\cron.php > C:\MoodleWindowsInstaller-latest-33\server\moodle\admin\cron.log
PHP Warning:  Module 'openssl' already loaded in Unknown on line 0

I also tried turning off "Cron execution from command line only" (cronclionly), in case that might help. Clear caches didn't have any affect either.

What other steps can I take to clean up my disk without breaking Moodle? I've seen plenty of suggestions for a Linux environment, but I'm not sure how to adapt them for Windows 10. Did I miss something in the docs?

Thanks, in advance

Average of ratings: -
In reply to Ryan Carpenter

Re: filedir Clean up in Windows

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

So  there's two parts to what you see:

  1. The "PHP Warning:  Module 'openssl' already loaded in Unknown on line 0" message should be just that, a warning. There's maybe something wrong in your php.ini causing that error but it shouldn't affect the cron running.
  2. The cron output. The last part of your command, > C:\MoodleWindowsInstaller-latest-33\server\moodle\admin\cron.log, is sending all the non-error output to this file. If it's not present there's another problem.

So try just running the cron without the > redirect, i.e. just run C:\MoodleWindowsInstaller-latest-33\server\php\php.exe -f C:\MoodleWindowsInstaller-latest-33\server\moodle\admin\cli\cron.php. You should hopefully see messages output directly, what do they say?

In reply to Ryan Carpenter

Re: filedir Clean up in Windows

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

If it's the case that there's something going wrong in Moodle or the environment (e.g. Apache crashing mid-operation) causing these files to get left behind in moodledata\filedir then the Moosh utility has a check, file-dbcheck, which reports files in filedir that aren't in the database.

I had a quick go at a simple script to do this. To run it: save it, go to the command line, change to the Moodle source code folder (e.g. cd C:\MoodleWindowsInstaller-latest-33\server\moodle), and run it with PHP (e.g. C:\MoodleWindowsInstaller-latest-33\server\php\php -f C:\path\to\orphan.php). If everything is fine you should get no output. If there are any files Moodle has somehow lost they'll be listed, e.g.:

Not in database: 9a/91/91cfeee5884a43a4650a851f4f85e7b28316fcc9

Any files listed Moodle doesn't know about so they can almost certainly be deleted but I'd recommend taking a backup copy before deleting them just in case

Average of ratings: Useful (1)