October 19, 2025Oct 19 so i trying to make the array keep spun up between 9am to 9pm and then after that 15 min spin down i got the crontab settingsbut when i google how to do the code it doesnt workive tried thisroot@Tardis:~# /root/mdcmd spinup disk1bash: /root/mdcmd: No such file or directoryroot@Tardis:~# mdcmdusage: mdcmd <command> [arg ... ]root@Tardis:~# mdcmd spinup disk1/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argumentroot@Tardis:~# sudo mdcmd spinup disk1/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argumentroot@Tardis:~# for disknum in ls /dev/md* | sed "sX/dev/mdXX"; do /root/mdcmd spinup $disknum; donebash: /root/mdcmd: No such file or directorybash: /root/mdcmd: No such file or directorybash: /root/mdcmd: No such file or directorybash: /root/mdcmd: No such file or directorybash: /root/mdcmd: No such file or directorybash: /root/mdcmd: No such file or directorybash: /root/mdcmd: No such file or directoryroot@Tardis:~# for disknum in ls /dev/md* | sed "sX/dev/mdXX"; do mdcmd spinup $disknum; done/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argument/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argument/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argument/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argument/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argument/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argument/usr/local/sbin/mdcmd: line 35: echo: write error: Invalid argumentroot@Tardis:~# ^Cso not sure how you make it work
October 19, 2025Oct 19 Community Expert alot worng here and using bad AI and comands to do this...I can help make a stop start scirpt at time..#!/usr/bin/env bash set -euo pipefail ######################################### # CONFIGURATION ######################################### # Time window for stopping/starting STOP_TIME="21:10" # 9:10 PM START_TIME="08:50" # 8:50 AM # Log file for status tracking LOG_FILE="/var/log/unraid-array-scheduler.log" ######################################### # INTERNALS ######################################### CURRENT_TIME=$(date +%H:%M) CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini || true) COOKIE=/tmp/unraid.cookies log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG_FILE" } stop_array() { log "Stopping array..." curl -sS -k --fail -e "http://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \ http://localhost/update.htm \ || curl -sS -k --fail -e "https://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \ https://localhost/update.htm sleep 5 grep -E '^(mdState|fsState)=' /var/local/emhttp/var.ini | tee -a "$LOG_FILE" } start_array() { log "Starting array..." curl -sS -k --fail -e "http://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \ http://localhost/update.htm \ || curl -sS -k --fail -e "https://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \ https://localhost/update.htm sleep 5 grep -E '^(mdState|fsState)=' /var/local/emhttp/var.ini | tee -a "$LOG_FILE" } current_state() { grep -Po '^mdState="\K[^"]+' /var/local/emhttp/var.ini 2>/dev/null || echo "UNKNOWN" } ######################################### # MAIN LOGIC ######################################### STATE=$(current_state) log "Current time: $CURRENT_TIME | Array state: $STATE" if [[ "$CURRENT_TIME" == "$STOP_TIME" ]]; then if [[ "$STATE" == "STARTED" ]]; then stop_array else log "Array already stopped. No action needed." fi elif [[ "$CURRENT_TIME" == "$START_TIME" ]]; then if [[ "$STATE" == "STOPPED" ]]; then start_array else log "Array already started. No action needed." fi else log "No action scheduled for $CURRENT_TIME." fi Cron every 30 min to run and check...*/30 * * * *some other plugins for spin down and other are needed... as stopping the array kills vms, docker s etc...but if something running like a database or other task the disk will not spin down... Edited October 19, 2025Oct 19 by bmartino1
October 19, 2025Oct 19 Author @bmartino1 so i looked at the link that is just for stop and starting the array but thats not what i wantwhat i trying to do is keep the array disks always spun up and not go to standby mode. sorry if my dislexia screwed things up in my orginal post i was saying i wanna keep the array disks spun up between 9am to 9pm after that it can go into standby mode after 15 minand that i already got the crontab to run every 10 min between 9 to 9
October 19, 2025Oct 19 Author so like /root/mdcmd spinup disk1 should make disk 1 spin up but doesntand this linefor disknum in ls /dev/md* | sed "sX/dev/mdXX"; do /root/mdcmd spinup $disknum; donesupposed to spin up all the drives from standby but it complains about the mdcmd
October 19, 2025Oct 19 Community Expert 1 minute ago, comet424 said:@bmartino1 so i looked at the link that is just for stop and starting the array but thats not what i wantwhat i trying to do is keep the array disks always spun up and not go to standby mode.sorry if my dislexia screwed things up in my orginal post i was saying i wanna keep the array disks spun up between 9am to 9pm after that it can go into standby mode after 15 minand that i already got the crontab to run every 10 min between 9 to 9understood, thsi coudl still be adapted as standby/sleep states.esentail we still want a array stop start durring the time. and introduce a sleep comand and when on to start the array..untested code as I don't nomalry hit nor use the spin up spin down buttons... #!/usr/bin/env bash set -euo pipefail ######################################### # CONFIGURATION ######################################### # Active spin-up window (24-hour format) START_HOUR=9 # 9 AM STOP_HOUR=21 # 9 PM # Log file LOG_FILE="/var/log/unraid-keep-spunup.log" ######################################### # INTERNALS ######################################### HOUR=$(date +%H) CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini || true) COOKIE=/tmp/unraid.cookies log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG_FILE" } spin_up_all() { log "Spinning up all array disks..." curl -sS -k --fail -e "http://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpinupAll=Spinup" \ http://localhost/update.htm \ || curl -sS -k --fail -e "https://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpinupAll=Spinup" \ https://localhost/update.htm } ######################################### # MAIN LOGIC ######################################### if (( HOUR >= START_HOUR && HOUR < STOP_HOUR )); then spin_up_all else log "Outside active window (array may spindown normally)." fi I belve this is what you want regardign to spin up of the disk only...In the User Scripts plugin, schedule it for:*/10 9-21 * * * → runs every 10 minutes between 9 AM and 9 PM.
October 19, 2025Oct 19 Author k that code doesnt work i copy and pasted the lineroot@Tardis:~# log "Spinning up all array disks..." curl -sS -k --fail -e "http://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpinupAll=Spinup" \ http://localhost/update.htm \ || curl -sS -k --fail -e "https://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpinupAll=Spinup" \ https://localhost/update.htmbash: log: command not foundcurl: option -c: blank argument where content is expectedcurl: try 'curl --help' or 'curl --manual' for more informationcurl: option -c: blank argument where content is expectedcurl: try 'curl --help' or 'curl --manual' for more informationroot@Tardis:~# curl -sS -k --fail -e "http://localhost/Main" -c "$COOKIE" -b "$COOKIE" --data "csrf_token=${CSRF}&cmdSpinupAll=Spinup" http://localhost/update.htm || curl -sS -k --fail -e "https://localhost/Main" -c "$COOKIE" -b "$COOKIE" --data "csrf_token=${CSRF}&cmdSpinupAll=Spinup" https://localhost/update.htmcurl: option -c: blank argument where content is expectedcurl: try 'curl --help' or 'curl --manual' for more informationcurl: option -c: blank argument where content is expectedcurl: try 'curl --help' or 'curl --manual' for more informationroot@Tardis:~#
October 19, 2025Oct 19 Author but i guess its gotta be in the script to run so ill try a copy and paste in a script
October 19, 2025Oct 19 Community Expert I need to think more on that as I nromal aviod and turn off sleep states as if the machien is going to do the task budget and set it up to be 24/7from runnign or using sleep states and to other disk activity. I'm not quite sure how to aproch this even form the termal runnign spin up and down comands as this can hurt active didsk doing tasks... I need to re reveiwe the urniad dos on spin up and down...https://forums.unraid.net/topic/129313-how-do-i-automate-spinning-down-specific-disks/ I also think this may be semi in the web UI with disk settings...
October 19, 2025Oct 19 Author @bmartino1 supposedly from the google AI search you just type for disknum in ls /dev/md* | sed "sX/dev/mdXX"; do /root/mdcmd spinup $disknum; doneand that spins up the array of all the disks but it doesnt like the mdcmd
October 19, 2025Oct 19 Community Expert as I'm using a ZFS SYSTEM.. I have no disk 1 to test this should be the comand to spin down disk 1 as if you hit the spin down#!/usr/bin/env bashset -euo pipefailCSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini)COOKIE=/tmp/unraid.cookiescurl -sS -k --fail -e "http://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpindown=disk1" \ http://localhost/update.htm \|| \curl -sS -k --fail -e "https://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpindown=disk1" \ https://localhost/update.htm
October 19, 2025Oct 19 Community Expert Just now, comet424 said:@bmartino1supposedly from the google AI searchyou just typefor disknum in ls /dev/md* | sed "sX/dev/mdXX"; do /root/mdcmd spinup $disknum; doneand that spins up the array of all the disks but it doesnt like the mdcmdis bad old data in v6 that never worked ... the mdctl is form debain mdadm stuff that unraid donw't use to make its software raid. unraid uses scritps taht run under the emhttp and slackware system vars to make the array parity and other software raid. that would be a good quick data to try with debain not unraid slackware
October 19, 2025Oct 19 Author ill try that what i currently have /root/mdcmd spinup disk1/root/mdcmd spinup disk2/root/mdcmd spinup disk3/root/mdcmd spinup disk4/root/mdcmd spinup disk5/root/mdcmd spinup disk6/root/mdcmd spinup disk7but that doesnt work
October 19, 2025Oct 19 Author so it didnt like that codeScript location: /tmp/user.scripts/tmpScripts/Keep Hard Drives Spun Up/scriptNote that closing this window will abort the execution of this scriptcurl: (2) no URL specifiedcurl: try 'curl --help' or 'curl --manual' for more information
October 19, 2025Oct 19 Community Expert @comet424 The ‘mdcmd’ command that is in Unraid is a custom version and not the standard Linux variant so you cannot assume it works like it would on other Linux systems.
October 19, 2025Oct 19 Author @itimpi i wouldnt know i googled how to keep array disks spun up in unraid command lineand the google AI spit out those commands for unraid..but since didnt work thats why i figured id ask here how to do it Edited October 19, 2025Oct 19 by comet424
October 19, 2025Oct 19 Community Expert apologies as I'm at a trail and error at this point with code scripting... try to spin them all down...one copy paste...#!/usr/bin/env bashset -euo pipefailCSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini)COOKIE=/tmp/unraid.cookies# Try HTTP first, then HTTPScurl -sS -k --fail -e "http://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpindownAll=Spindown" \ http://localhost/update.htm \|| \curl -sS -k --fail -e "https://localhost/Main" \ -c "$COOKIE" -b "$COOKIE" \ --data "csrf_token=${CSRF}&cmdSpindownAll=Spindown" \ https://localhost/update.htmBehaviorTells Unraid’s emhttpd backend to issue spindown commands to every array + pool disk.Exactly mirrors the “Spin Down All” button on the Main page.Safe to run any time — it won’t stop the array or unmount anything.You can schedule this with cron or the User Scripts plugin for after-hours power saving.I remember other termianl comands that afected spin up and down via termanl but untests and lost onth forum. Sorry I can't be of much help...as I would have to go thoguht the unraid githbu web ui and try to find the coamnd they run adn add it to the data line of this script to do what it would do as if you hit the button inthe main page...urnaid web ui githubhttps://github.com/unraid/webgui/blob/master/emhttp/plugins/dynamix/Main.page GitHubwebgui/emhttp/plugins/dynamix/scripts at master · unraid/...Unraid Web UI. Contribute to unraid/webgui development by creating an account on GitHub.either that or a higher dev/mod may know...
October 19, 2025Oct 19 Community Expert https://docs.unraid.net/unraid-os/using-unraid-to/manage-storage/array-configuration/#spinning-disks-down-or-up
October 19, 2025Oct 19 Author @bmartino1 ya that code didnt help either Script location: /tmp/user.scripts/tmpScripts/Keep Hard Drives Spun Up/scriptNote that closing this window will abort the execution of this scriptcurl: (2) no URL specifiedcurl: try 'curl --help' or 'curl --manual' for more informationok ill check out that link
October 19, 2025Oct 19 Author @bmartino1 that link didnt help either just only shows about clicking the circles but i appreciate your help.. i also going to try google more someone has had to solve this issue
October 19, 2025Oct 19 Author and ive tried also the hdparm -y /dev/sdbbut it didnt like that command either
October 19, 2025Oct 19 Author just running hdparm it doesnt even have an option to spin up a drive the -y puts the drive in standby modegoogle ai is nice but sometimes crap lol
October 19, 2025Oct 19 Community Expert hdparm -y /dev/sd{b,c,d,e,g,h}etc is a Hard dis parameter taht is lower level then what urnaid spin up and spin down does...that won't reflecet itn eh web ui as well and require hdparm to wake up sometimes.even if the comand worked to what makes this smei hard is finding what uraid calls the comadns now...Unraid ≥ 6.12 uses this format for the GUI “Spin Down All” and “Spin Up All” buttons:ActionPOST fieldCommentSpin down allcmdSpinDownAll=SpinDownAllnote the capital D and ASpin up allcmdSpinUpAll=SpinUpAllsame patternI'm not finding the odler form data on spin down spin up as well.
October 19, 2025Oct 19 Community Expert so i would go to settings > disk settings and let teh disk go into a spun down state when they are idle for 15 min.. this mean no dockers, no file copy no disk activty and they will spin down..you may want to enable spin groups and setup spin groupsI rember a feature chat from the dev checking if people used theses... so they kept it as this would be ther only other area that I can think of that can edite or messs with spin up spin down... Edited October 19, 2025Oct 19 by bmartino1
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.