Windows Server ScheduledDefrag Task Schedule not running

%3CLINGO-SUB%20id%3D%22lingo-sub-356798%22%20slang%3D%22en-US%22%3EWindows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-356798%22%20slang%3D%22en-US%22%3E%3CP%3EAll%20my%20Windows%20server%20(2008%20R2%20and%20above)%20unable%20to%20run%20scheduled%20task%20of%20disk%20defragmentation%3F%20I%20had%20turn%20on%20the%20schedule%20defragmentation%20in%20disk%20defragmenter%20and%20set%20it%20run%20on%20weekly%20basic%2C%20but%2C%20it%20not%20run.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20schedule%20defragmentation%20had%20selected%20all%20drive%20to%20defragment.%26nbsp%3BBelow%20is%20one%20of%20the%20server%20schedule%20defragmentation%20sample%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-left%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F84430i516FC984B0060268%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22Scheduledtask.JPG%22%20title%3D%22Scheduledtask.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20help%20to%20solve%20this%20problem%20else%20i%20need%20to%20manual%20do%20all%20my%20Windows%20server%20disk%20defragmentation%20by%20monthly.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-356798%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358035%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358035%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20find%20most%20here.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fdefrag%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fdefrag%3C%2FFONT%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EThe%20%3CSTRONG%3E%24%3C%2FSTRONG%3E%20may%20have%20to%20do%20with%20priority.%20If%20it%20runs%20Ok%20using%26nbsp%3B%3CSTRONG%3E%3CSPAN%20style%3D%22text-align%3A%20left%3B%20color%3A%20%23333333%3B%20text-transform%3A%20none%3B%20text-indent%3A%200px%3B%20letter-spacing%3A%20normal%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20text-decoration%3A%20none%3B%20word-spacing%3A%200px%3B%20display%3A%20inline%20!important%3B%20white-space%3A%20normal%3B%20orphans%3A%202%3B%20float%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20%23ffffff%3B%22%3Edefrag.exe%20-c%3C%2FSPAN%3E%3C%2FSTRONG%3E%20then%20I'd%20probably%20go%20with%20that%20as%20acceptable.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358021%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358021%22%20slang%3D%22en-US%22%3E%3CP%3EI%20had%20removed%20the%20all%20the%20check%20inside%20the%20condition%20tab%20but%20still%20not%20defrag%20the%20drive%20when%20I%20run%20the%20task%20schedule.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20noticed%20if%20I%20change%20the%20action%20argument%20to%20defrag.exe%20-c%20only%2C%20then%20defrag%20will%20run.%3C%2FP%3E%3CP%3ECan%20I%20know%20what%20is%20the%20meaning%20of%20-h%20-k%20-g%20-%24%3F%20For%20your%20information%2C%20I%20using%20VM%20server.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-357986%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-357986%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20that%20looks%20correct.%20Might%20also%20check%20the%20task%20%3CSTRONG%3EConditions%3C%2FSTRONG%3E%20tab%20and%20remove%20the%20checks.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-357968%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-357968%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Dave%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20checked%20the%20event%20viewer%20log%26nbsp%3Band%20history%20in%20task%20scheduler%2C%20defrag%20schedule%20task%20had%20run.%20However%2C%20when%20we%20see%20the%20%22defragment%20and%26nbsp%3Boptimize%20drive%22%20application%2C%20it%20not%20defrag%20and%20optimize%20the%20drive.%20The%20drive%20still%20in%20high%20fragmented%20rate.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20default%20action%20of%20defrag%20schedule%20is%20correct%3F%3C%2FP%3E%3CP%3E%26nbsp%3BIt%20using%20below%20arguments%20for%20the%20defrag%3A%3C%2FP%3E%3CP%3E%25windir%25%5Csystem32%5Cdefrag.exe%20-c%20-h%20-k%20-g%20-%24%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-356958%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-356958%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22border-image-outset%3A%200%3B%20border-image-repeat%3A%20stretch%3B%20border-image-slice%3A%20100%25%3B%20border-image-source%3A%20none%3B%20border-image-width%3A%201%3B%20color%3A%20%232a2a2a%3B%20font-family%3A%20inherit%3B%20font-size%3A%2014px%3B%20font-style%3A%20inherit%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20inherit%3B%20letter-spacing%3A%20normal%3B%20list-style-type%3A%20none%3B%20orphans%3A%202%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%200px%3B%20margin%3A%200px%200px%201em%200px%3B%20border%3A%20medium%20none%20currentColor%3B%22%3EI'd%20check%20the%20logs%20at%3B%3C%2FP%3E%0A%3CP%20style%3D%22border-image-outset%3A%200%3B%20border-image-repeat%3A%20stretch%3B%20border-image-slice%3A%20100%25%3B%20border-image-source%3A%20none%3B%20border-image-width%3A%201%3B%20color%3A%20%232a2a2a%3B%20font-family%3A%20inherit%3B%20font-size%3A%2014px%3B%20font-style%3A%20inherit%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20inherit%3B%20letter-spacing%3A%20normal%3B%20list-style-type%3A%20none%3B%20orphans%3A%202%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%200px%3B%20margin%3A%200px%200px%201em%200px%3B%20border%3A%20medium%20none%20currentColor%3B%22%3E%3CSTRONG%3EEvent%20Viewer%5CApplications%5CMicrosoft%5CWindows%5CTaskScheduler%5COperational%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22border-image-outset%3A%200%3B%20border-image-repeat%3A%20stretch%3B%20border-image-slice%3A%20100%25%3B%20border-image-source%3A%20none%3B%20border-image-width%3A%201%3B%20color%3A%20%232a2a2a%3B%20font-family%3A%20inherit%3B%20font-size%3A%2014px%3B%20font-style%3A%20inherit%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20inherit%3B%20letter-spacing%3A%20normal%3B%20list-style-type%3A%20none%3B%20orphans%3A%202%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%200px%3B%20margin%3A%200px%200px%201em%200px%3B%20border%3A%20medium%20none%20currentColor%3B%22%3E(note%3A%20log%20may%20need%20to%20be%20%3CSTRONG%3EEnabled%3C%2FSTRONG%3E%20in%20right-hand%20pane)%3C%2FP%3E%0A%3CP%20style%3D%22border-image-outset%3A%200%3B%20border-image-repeat%3A%20stretch%3B%20border-image-slice%3A%20100%25%3B%20border-image-source%3A%20none%3B%20border-image-width%3A%201%3B%20color%3A%20%232a2a2a%3B%20font-family%3A%20inherit%3B%20font-size%3A%2014px%3B%20font-style%3A%20inherit%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20inherit%3B%20letter-spacing%3A%20normal%3B%20list-style-type%3A%20none%3B%20orphans%3A%202%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%200px%3B%20margin%3A%200px%200px%201em%200px%3B%20border%3A%20medium%20none%20currentColor%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22border-image-outset%3A%200%3B%20border-image-repeat%3A%20stretch%3B%20border-image-slice%3A%20100%25%3B%20border-image-source%3A%20none%3B%20border-image-width%3A%201%3B%20color%3A%20%232a2a2a%3B%20font-family%3A%20inherit%3B%20font-size%3A%2014px%3B%20font-style%3A%20inherit%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20inherit%3B%20letter-spacing%3A%20normal%3B%20list-style-type%3A%20none%3B%20orphans%3A%202%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%200px%3B%20margin%3A%200px%200px%201em%200px%3B%20border%3A%20medium%20none%20currentColor%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22border-image-outset%3A%200%3B%20border-image-repeat%3A%20stretch%3B%20border-image-slice%3A%20100%25%3B%20border-image-source%3A%20none%3B%20border-image-width%3A%201%3B%20color%3A%20%232a2a2a%3B%20font-family%3A%20inherit%3B%20font-size%3A%2014px%3B%20font-style%3A%20inherit%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20inherit%3B%20letter-spacing%3A%20normal%3B%20list-style-type%3A%20none%3B%20orphans%3A%202%3B%20outline-color%3A%20invert%3B%20outline-style%3A%20none%3B%20outline-width%3A%200px%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20padding%3A%200px%3B%20margin%3A%200px%200px%201em%200px%3B%20border%3A%20medium%20none%20currentColor%3B%22%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1091599%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1091599%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F291399%22%20target%3D%22_blank%22%3E%40Nivlee%3C%2FA%3E%26nbsp%3BI%20came%20across%20the%20same%20problem%20on%20our%20two%20Windows%202012%20servers.%20Defrag%20had%26nbsp%3B%3CSTRONG%3Enever%26nbsp%3B%3C%2FSTRONG%3Ebeen%20run%20and%20I%20suspect%20the%20reason%20is%20that%20there%20is%20no%20trigger%20on%20the%20ScheduledDefrag%20task%20which%20means%20it'll%20never%20run%20automatically.%20Changing%20the%20schedule%20in%20the%20optimisation%20tool%20from%20weekly%20to%20daily%20doesn't%20make%20any%20difference.%20I%20suspect%20this%20is%20a%20bug%20that's%20been%20around%20a%20long%20time...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20679px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163856iA25A902109524CE0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22nvPQwU8%5B1%5D.png%22%20title%3D%22nvPQwU8%5B1%5D.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI'm%20about%20to%20add%20a%20trigger%20to%20run%20it%20once%20a%20week%20and%20see%20what%20happens.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1091609%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1091609%22%20slang%3D%22en-US%22%3EI%20read%20elsewhere%20that%20the%20-%24%20flag%20indicates%20to%20defrag.exe%20that%20it's%20running%20as%20a%20scheduled%20task.%20It%20must%20make%20it%20do%20something%20different%20to%20when%20run%20from%20command%20line.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1112955%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1112955%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20general%2C%20some%20other%20scheduled%20task%20(don't%20know%20which)%20runs%20ScheduledDefrag.%20That%20is%20why%20its%20triggers%20are%20empty.%20I%20suppose%2C%20with%20some%20care%2C%20triggers%20could%20be%20added.%20It%20is%20too%20bad%20that%20Microsoft%20allows%20but%20doesn't%20show%20such%20cascaded%20schedules.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1585535%22%20slang%3D%22en-US%22%3ERe%3A%20Windows%20Server%20ScheduledDefrag%20Task%20Schedule%20not%20running%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1585535%22%20slang%3D%22en-US%22%3EI'm%20seeing%20all%20the%20same%20symptoms%20on%20my%20server.%20I%20just%20optimized%20my%20SSD%20for%20the%20first%20time%20since%20I%20installed%20it.%20Before%20that%2C%20it%20was%20showing%20%22Never%20run%22.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20too%20have%20the%20blank%20list%20of%20drives%20under%20the%20Choose%20button.%3CBR%20%2F%3E%3CBR%20%2F%3EOne%20extra%20thing%20I%20noticed%20is%20that%20the%20scheduled%20task%20does%20get%20triggered%20and%20it%20does%20log%20a%20service%20start%20and%20stop%20in%20the%20System%20log%2C%20but%20then%20it%20seems%20like%20nothing%20else%20happens.%20So%20maybe%20I%20need%20to%20adjust%20the%20scheduled%20Action%20as%20mentioned%20above.%3C%2FLINGO-BODY%3E
New Contributor

All my Windows server (2008 R2 and above) unable to run scheduled task of disk defragmentation? I had turn on the schedule defragmentation in disk defragmenter and set it run on weekly basic, but, it not run. 

 

In the schedule defragmentation had selected all drive to defragment. Below is one of the server schedule defragmentation sample:

Scheduledtask.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I need help to solve this problem else i need to manual do all my Windows server disk defragmentation by monthly. 

10 Replies

I'd check the logs at;

Event Viewer\Applications\Microsoft\Windows\TaskScheduler\Operational

(note: log may need to be Enabled in right-hand pane)

 

 

 

Hi Dave,

 

I checked the event viewer log and history in task scheduler, defrag schedule task had run. However, when we see the "defragment and optimize drive" application, it not defrag and optimize the drive. The drive still in high fragmented rate.

 

The default action of defrag schedule is correct?

 It using below arguments for the defrag:

%windir%\system32\defrag.exe -c -h -k -g -$

Yes, that looks correct. Might also check the task Conditions tab and remove the checks.

 

 

I had removed the all the check inside the condition tab but still not defrag the drive when I run the task schedule.

 

I noticed if I change the action argument to defrag.exe -c only, then defrag will run.

Can I know what is the meaning of -h -k -g -$? For your information, I using VM server.

You can find most here.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/defrag

 

The $ may have to do with priority. If it runs Ok using defrag.exe -c then I'd probably go with that as acceptable.

 

 

@Nivlee I came across the same problem on our two Windows 2012 servers. Defrag had never been run and I suspect the reason is that there is no trigger on the ScheduledDefrag task which means it'll never run automatically. Changing the schedule in the optimisation tool from weekly to daily doesn't make any difference. I suspect this is a bug that's been around a long time...

 

nvPQwU8[1].png

I'm about to add a trigger to run it once a week and see what happens.

I read elsewhere that the -$ flag indicates to defrag.exe that it's running as a scheduled task. It must make it do something different to when run from command line.

In general, some other scheduled task (don't know which) runs ScheduledDefrag. That is why its triggers are empty. I suppose, with some care, triggers could be added. It is too bad that Microsoft allows but doesn't show such cascaded schedules.

I'm seeing all the same symptoms on my server. I just optimized my SSD for the first time since I installed it. Before that, it was showing "Never run".

I too have the blank list of drives under the Choose button.

One extra thing I noticed is that the scheduled task does get triggered and it does log a service start and stop in the System log, but then it seems like nothing else happens. So maybe I need to adjust the scheduled Action as mentioned above.

Your post mentioned Server 2008, but 2008 does not have the arguments of -k -g -$ (in fact, 2008 uses / for arguments, not -), therefore your defrag would immediately exit out with an error status. That likely explains your issue.
Hold your WINDOWS key and tap R and type in CMD and tap enter. There type in DEFRAG.EXE /? and hit enter. Server 2008 has very limited options, nothing for file optimization (which moves the most important files to fastest portions of your disk).
Moreover, you probably should use the Degrag setting that comes in Task Scheduler already. Hold WINDOWS and tap R and type in TASKSCHD.MSC , in the popup's left pane navigate to TASK SCHEDULER LIBRARY > MICROSOFT > WINDOWS > DEFRAG

 

If you want to optimize your files as well, I suggest Auslogics Disk Defrag, it works on all Windows versions & is very fast when compared to Windows' built-in defrag.exe .  If you can get an old version of Ausologics Disk Defrag, it will lack the annoying options to "buy now" and it also lacks the install of Auslogic's other products as trial versions.  Unfortunately, it cannot be scheduled without purchasing, and the old version lacks optimizations for SSD (solid state) drives.


I hope this helps?
Have a great day!
JohnNeu