Menu

UltraDefrag 9.0.0 Scheduling Questions

Help
Jamil
2019-10-11
2019-10-12
  • Jamil

    Jamil - 2019-10-11

    I upgraded to 9.0.0 enterprise recently, and it has been working great with no issues so far. I am currently using this as my only defrag tool, and I have some questions related to scheduling.

    I want to create a quick defrag script that gets executed during idle times. Creating the script itself is no issue for me, but the scheduling portion of it I have specific requirements. For my workstation, I generally leave it powered on 24/7. It is scheduled to execute lots of tasks. I know that Windows Task Scheduler is used for scheduling. In reviewing it, I am not seeing a way to have it not execute a task if other processes are currently executing. I do not want a defrag job to execute when VMWare Workstation is currently executing (C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe). Also, I do not want a defrag job to execute if DivX Converter is currently converting videos (C:\Program Files (x86)\DivX\DivX Converter\DivXConverter.exe). If I may stop a scheduled task from starting when either of these two processes are executing, this would meet my needs.

    Every Saturday morning starting at midnight my workstation executes weekly patrol reads that execute for around seven hours. I do not want a scheduled defrag job to execute during this time. In this case, this is MegaRAID Storage Manager that kicks off the scheduled job. This is a Java based application that has a fixed schedule. I do not know of a specific process to look for, but I do not want any defrag jobs to execute from midnight each Saturday until 8AM. Additionally, every month MegaRAID executes a consistency check that also runs for at least seven hours. I have this scheduled to execute the first of every month also starting at midnight.

    Any thoughts on ways to schedule defrag jobs based on the above?

    Thanks.

     

    Last edit: Jamil 2019-10-11
  • Dmitri Arkhangelski

    Hello,

    As far as I know it is impossible to adjust scheduled tasks so they won't get executed if some other processes are running, so you probably have to write a special program which will run in background and check whether the processes are running or not, for instance, every second. Then, if it detects the processes are running it might stop the defragmentation using the schtasks command and maybe reschedule it using the same command afterwards.

    Best regards,
    Dmitri

     
    • Jamil

      Jamil - 2019-10-11

      Thanks for the response.

      It looks like I can schedule PowerShell scripts to execute that have the ability to check for running processes as well as date/time checks combined. When all conditions are met, I could then launch UltraDefrag. I will experiment with this. This looks to be one way to go about this without too much work.

       
  • Jamil

    Jamil - 2019-10-12

    EDIT: below is my revised and complete PowerShell script that includes all functionality I require; added a couple more processes that prevent scheduled defrag; fixed conditions.

    I am posting this update if anyone else wishes to use this:

    #
    # UltraDefragScheduledLaunch.ps1
    #
    
    $vmware = Get-Process vmware -ErrorAction SilentlyContinue
    $divx = Get-Process DivXConverter -ErrorAction SilentlyContinue
    $macrium = Get-Process reflectbin -ErrorAction SilentlyContinue
    $ultradefrag = Get-Process ultradefrag -ErrorAction SilentlyContinue
    $weekday = Get-Date -UFormat "%A"
    [int]$hour = Get-Date -UFormat "%H"
    [int]$dayofmonth = Get-Date -UFormat "%d"
    
    if ($vmware -eq $null -and $divx -eq $null -and $macrium -eq $null -and $ultradefrag -eq $null) {
        if (($dayofmonth -ine 28 -or ($dayofmonth -eq 28 -and $hour -gt 7)) -and 
            (($weekday -eq "Friday" -and $hour -le 23) -or
             ($weekday -eq "Saturday" -and $hour -gt 7) -or
             ($weekday -ine "Friday" -and $weekday -ine "Saturday"))) {
                &"C:\Program Files\UltraDefrag\task-launcher.exe" "C:\Program Files\UltraDefrag\tasks\auto-defrag-custom.cmd"
            }
        }
    
    Remove-Variable vmware
    Remove-Variable divx
    Remove-Variable macrium
    Remove-Variable ultradefrag
    Remove-Variable weekday
    Remove-Variable hour
    Remove-Variable dayofmonth
    

    If either VMWare Workstation, DivX Converter, Macrium Reflect or the UltraDefrag UI are executing, the script will not launch the UltraDefrag task. Also, the time must be in the allowed period. The version above will not execute on the 28th day of every month unless the time is after 7AM. I changed the day that my consistency check runs to the 28th day of every month.

    To set this as a scheduled task, open Windows Task Schedule then edit the AutoDefrag task shown. Click the Actions tab then edit the Start a program action:

    Program/Script:  PowerShell.exe
    Add arguments (optional):  -ExecutionPolicy Bypass C:\Users\<user_name>\source\repos\UltraDefragScheduledLaunch\UltraDefragScheduledLaunch\UltraDefragScheduledLaunch.ps1
    
     

    Last edit: Jamil 2019-10-20

Log in to post a comment.