Kaseya Community

Script to clear disk space on servers

This question is not answered

Hi , 

My client need some scripts to do self healing in case any alerts are found for low disk space on servers and workstations.Can anybody share the procedure with me to do the disk cleanups on servers and workstations that can be utilized in monitor sets??

All Replies
  • W3SVC1\nul

  • @billmccl  Testing if the path exists, then it does the cleaning of it.

  • Do you execute as User or System?

  • System

  • I've tried this both ways, but it's not deleting anything - I know there are files there > 30 days

    executeShellCommand Forfiles.exe -p C:\Windows\System32\LogFiles\W3SVC1\ -m *.log -d -30 -c "Cmd.exe /C del @path" -s

  • Hmmm.   Looks like what I have.  Might be something with the 2003.  I would make a copy of the W3SVC folder, just so you have something to copy back in and keep testing with.  But I would first off try running the Forfiles.exe -p C:\Windows\System32\LogFiles\W3SVC1\ -m *.log -d -30 -c "Cmd.exe /C del @path" -s from a command prompt on the server and see if it works.  If so, copy the W3SVC1 files back in and try adding a an impersonateUser that has admin rights and see if that works or not.

  • I ran the command manually and it worked just fine. I then copied files back into the original folder, ran the script with Impersonate User, but it didn't delete any files.

  • Procedure C-Drive Server Disk Cleanup.xml

    I had some issues with quotes in the procedure. I got it to work and will try to attach the Exported version of the agent Procedure.