Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Start/Stop Array via CLI

Featured Replies

Since the dashboard now requires a csrf-token, the old wget-method does not work anymore: 

 

Is there any way to locally execute the array start/stop functions directly or is there a command for it?

 

I have searched through tons of includes, php, template files and couldn't find where they actually execute it - besides all POSTing to the same endpoint. Of course a solution could be to have a headless browser or requests that regex out the csrf token prior, but it'd be much easier to just have something e.g. executed via ssh if available.

 

Thank you in advanced!

  • Author

@Squid Thanks! I guess it checks both for get and post values? because all forms I could find were doing a post exclusively. Based on what you said that should work, will try it in an hour or two to confirm:

#!/bin/bash
CSRF=$(cat /var/local/emhttp/var.ini | grep -oP 'csrf_token="\K[^"]+')
wget -qO /dev/null http://localhost:$(lsof -nPc emhttp | grep -Po 'TCP[^\d]*\K\d+')/update.htm?cmdStart=Start&csrf_token=$CSRF

 

  • Author

@Squid Sadly didn't work, but the var.ini was the solution still!

 

Start:

#!/bin/bash
CSRF=$(cat /var/local/emhttp/var.ini | grep -oP 'csrf_token="\K[^"]+')
curl -k --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" http://localhost/update.htm

Stop:

#!/bin/bash
CSRF=$(cat /var/local/emhttp/var.ini | grep -oP 'csrf_token="\K[^"]+')
curl -k --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" http://localhost/update.htm

 

Edited by fsix

  • 3 years later...

I needed to start the array from a different system, so I ended up doing this:

#!/bin/bash
CSRF=$(ssh [email protected] "sed -n 's/^csrf_token=//p' /var/local/emhttp/var.ini|tr -d '\"'")
curl -k --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" http://192.168.88.235/update.htm

 

When using Unraid 6.10, you can simply use the following

 

Start array

#!/bin/bash
emcmd cmdStart=Start

 

Stop array

#!/bin/bash
emcmd cmdStop=Stop

 

  • 3 months later...

Is there a way to define the keyfile when starting the array with emcmd cmdStart=Start? Staging the keyfile in /root before running the command doesn't seem to work

Edited by solidno8

  • 3 years later...
  • Community Expert

updated command for 7.1.4

https://forums.unraid.net/topic/50490-solved-commands-to-start-and-stop-array/#findComment-1584966

7.1.4 1 line terminal command to stop the array... As if you hit the stop button on the main tab

stop array:

CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini)
# try HTTP first
curl -sS -k --fail -e "http://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \
  http://localhost/update.htm || \
# fallback to HTTPS
curl -sS -k --fail -e "https://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \
  https://localhost/update.htm

stat array:

CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini)

curl -sS -k --fail -e "http://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \
  http://localhost/update.htm || \
curl -sS -k --fail -e "https://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \
  https://localhost/update.htm

*ASUMES A VALD ARRAY CONFIG!!!

Verify and check:
root@The-Borg:~# grep -E '^(mdState|fsState)=' /var/local/emhttp/var.ini

mdState="STARTED"

fsState="Started"

root@The-Borg:~#

Why these parameters? Because the GUI’s JS adds a hidden cmdStop=Stop input and posts to /update.htm with csrf_token, plus a startState field (STARTED when stopping, STOPPED when starting) and an empty file param. Community-confirmed payloads (worked for others when GETs failed):

Tested on the borg and saw array shuting down per web ui and array start per web ui...

  • 5 months later...
On 10/19/2025 at 11:24 PM, bmartino1 said:

updated command for 7.1.4

https://forums.unraid.net/topic/50490-solved-commands-to-start-and-stop-array/#findComment-1584966

7.1.4 1 line terminal command to stop the array... As if you hit the stop button on the main tab

stop array:

CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini)
# try HTTP first
curl -sS -k --fail -e "http://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \
  http://localhost/update.htm || \
# fallback to HTTPS
curl -sS -k --fail -e "https://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STARTED&file=&csrf_token=${CSRF}&cmdStop=Stop" \
  https://localhost/update.htm

stat array:

CSRF=$(grep -Po '^csrf_token="\K[^"]+' /var/local/emhttp/var.ini)

curl -sS -k --fail -e "http://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \
  http://localhost/update.htm || \
curl -sS -k --fail -e "https://localhost/Main" \
  -c /tmp/unraid.cookies -b /tmp/unraid.cookies \
  --data "startState=STOPPED&file=&csrf_token=${CSRF}&cmdStart=Start" \
  https://localhost/update.htm

*ASUMES A VALD ARRAY CONFIG!!!

Verify and check:
root@The-Borg:~# grep -E '^(mdState|fsState)=' /var/local/emhttp/var.ini

mdState="STARTED"

fsState="Started"

root@The-Borg:~#

Why these parameters? Because the GUI’s JS adds a hidden cmdStop=Stop input and posts to /update.htm with csrf_token, plus a startState field (STARTED when stopping, STOPPED when starting) and an empty file param. Community-confirmed payloads (worked for others when GETs failed):

Tested on the borg and saw array shuting down per web ui and array start per web ui...

If using user script, we can't use just for 7.2.4 or 7.3betaX?

emcmd cmdStart=Start

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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.