Jellyfin Forum
Windows's Command Line - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Windows's Command Line (/t-windows-s-command-line)



Windows's Command Line - Nast - 2023-07-25

Hello,
Is there a command to stop the web server or stop jellyfin completely in windows?


RE: Windows's Command Line - qwerty12 - 2023-07-25

Hi,

One way to do it is this:
  1. Go to http://127.0.0.1:8096/web/index.html#!/apikeys.html and add an API key
  2. Run
    Code:
    curl "http://127.0.0.1:8096/System/Shutdown" -X POST -H "X-Emby-Token: 123456789abcde"


Replace the host and port if necessary. Replace 123456789abcde with the API key you generated earlier. I think you can authenticate via a username and password instead of generating an API key, but I don't know how, and I think using an API key for this task is better. curl.exe is included with Windows since Windows 10. If it is not present, you can use PowerShell to achieve the same thing:
Code:
Invoke-WebRequest -UseBasicParsing -Uri "http://127.0.0.1:8096/System/Shutdown" -Method POST -Headers @{ "X-Emby-Token" = "123456789abcde" }

Otherwise:

If, contrary to the Windows installer's recommendation, you installed Jellyfin in service mode, a simple net stop JellyfinServer in an elevated Command Prompt* on the same system where Jellyfin is running should also work.

If you're using the tray app, a PowerShell script that uses GenerateConsoleCtrlEvent should also work, but that's a long story.

* Or change the ACL on the Jellyfin service to allow stopping as a normal user - look into sc sdset or System Informer for a GUI


There might be more ways to do it that I'm unaware of. Avoid taskkill though - Jellyfin doesn't listen for window messages so it will cause unclean Jellyfin shutdowns.


RE: Windows's Command Line - skribe - 2023-07-25

I believe that the 10.9 release will include some shutdown and restart improvements to also make this sort of thing easier to accomplish from the dashboard as well.


RE: Windows's Command Line - wanderman - 2024-05-15

(2023-07-25, 02:28 PM)qwerty12 Wrote:
Code:
curl "http://127.0.0.1:8096/System/Shutdown" -X POST -H "X-Emby-Token: 123456789abcde"

What would the call look like for a startup request ?


RE: Windows's Command Line - TheDreadPirate - 2024-05-15

You cannot start Jellyfin with the same mechanism as the quoted shutdown. The quoted example is sending a command to a running jellyfin instance. You would start jellyfin on the command line simply by invoking jellyfin.exe and providing the appropriate startup options.


RE: Windows's Command Line - wanderman - 2024-05-16

Ok thanks for the response. I was asking as i had problems with my old setup of shutting down the tray exe & jellyfin exe to be able to run a backup task. My old method seems to be broken since 1.9. as im no more able to properly kill both exes, either by normal or forced kill. One of both always keeps running.

However i found a solution, might help someone in the future. Im running a nightly FreeFileSync Backup for my database, thats why i need jellyfin stopped to not get corrupted files into the backup folder. The following is my Windows batch.

The Batch as well as FreeFileSync is started by using the Windows Task Scheduler

Shutdown via api call - short timer while FreeFileSync is running - Restarting

Code:
curl "http://192.168.178.71:8096/System/Shutdown" -X POST -H "X-Emby-Token: #####APIKEY####"

TIMEOUT /T 1140 /NOBREAK

start C:\"Program Files"\Jellyfin\Server\Jellyfin.exe



RE: Windows's Command Line - qwerty12 - 2024-05-17

(2024-05-16, 07:24 PM)wanderman Wrote: The Batch as well as FreeFileSync is started by using the Windows Task Scheduler

The Task Scheduler starts programs with below normal CPU priority by default, BTW. Consider tacking on a /NORMAL somewhere in your start command to have Jellyfin run with a standard CPU priority.