Read the statement by Michael Teeuw here.
Command line to stop MM
-
It says “Missing Script: stop”
-
Did you run it from the MagicMirror directory?
If so, then NPM is ignoring it’s own documentation. I can’t help further, as I run it through PM2, and PM2 does the magic for me.
-
@l951b951 if you did it that way, ctrl-c should stop it without problem.
If u did
npm start &
Then you will have to kill the processes to stop it.
i wrote a little script to do it
#!/bin/bash ps aux | grep node | grep -v "color" | awk '{print $2}' | xargs sudo kill -9
the script will also work from another process instance
-
I ran it from ~/MagicMirror so I was in the directory. and all I typed was npm start.
My problem is that I want to be able to fire a script after a set time to stop the Magic Mirror. My goal is to attach a PIR motion sensor, and when someone comes close start the magic mirror, and after a few minutes with no motion, stop Magic Mirror and run another script. Maybe that helps understand my intent.
-
@sdetweil said in Command line to stop MM:
ps aux | grep node | grep -v “color” | awk ‘{print $2}’ | xargs sudo kill -9
Thank you for that. It worked, but gives me this: is it safe to ignore these warnings?
./run-start.sh: line 67: 3306 Killed electron js/electron.js $1 npm ERR! code ELIFECYCLE npm ERR! errno 137 npm ERR! magicmirror@2.10.1 start: `./run-start.sh` npm ERR! Exit status 137 npm ERR! npm ERR! Failed at the magicmirror@2.10.1 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /home/pi/.npm/_logs/2020-02-03T20_03_35_641Z-debug.log
-
@l951b951 yes.,… if you start mm like this
npm start >/dev/null 2>&1
you won’t get any messages
that means
send all stdout to /dev/null ( >/dev/null)
and send stderr to the same place as stdout (2>&1) -
Thank you, that combination is doing what I need it to do.
I’m marking this as solved, but I’d love to see a breakdown of what
ps aux | grep node | grep -v "color" | awk '{print $2}' | xargs sudo kill -9
is doing exactly?
-
list all the processes , one per line
ps aux
of that list get all lines that have the word ‘node’
grep node
of that list get all lines that DO NOT have the word color
grep -v “color”
use awk to print just the process number (second space separated token) from each line
awk ‘{print $2}’
and the use sudo kill -9 to kill it, passing the process number using xargs
xargs sudo kill -9 ???
you can do each as one step
ps aux (partial list)pi 922 0.0 0.4 6176 4208 pts/0 Ss Feb01 0:01 -bash root 14676 0.0 0.0 0 0 ? I< 12:34 0:00 [kworker/2:0H] pi 15250 0.0 0.2 4628 2644 ? Ss 13:55 0:00 bash /home/pi/MagicMirror/run-start.sh pi 15263 0.0 3.0 86264 28752 ? Sl 13:55 0:00 node node_modules/.bin/electron js/electron.js pi 15274 15.7 12.0 438576 113952 ? Sl 13:55 5:24 /home/pi/MagicMirror/node_modules/electron/dist/electron js/electron.js pi 15276 0.0 2.7 134932 26392 ? S 13:55 0:00 /home/pi/MagicMirror/node_modules/electron/dist/electron --type=zygote --no-sandbox pi 15311 8.2 10.8 342876 103308 ? Sl 13:55 2:49 /home/pi/MagicMirror/node_modules/electron/dist/electron --type=renderer --autoplay-po pi 15318 0.0 6.0 282764 57060 ? Sl 13:55 0:00 /home/pi/MagicMirror/n pu-process --no-sandbox --gpu-preferences=KAAAAAAAAACAAACAAQAAA root 15351 0.0 0.0 0 0 ? I 13:55 0:00 [kworker/3:2-eve]
with grep node
pi@raspberrypi:~ $ ps aux | grep node pi 15263 0.0 3.0 86264 28752 ? Sl 13:55 0:00 node node_modules/.bin/electron js/electron.js pi 15274 15.6 11.4 433072 108780 ? Sl 13:55 5:29 /home/pi/MagicMirror/node_modules/electron/dist/electron js/electron.js pi 15276 0.0 2.7 134932 26392 ? S 13:55 0:00 /home/pi/MagicMirror/node_modules/electron/dist/electron --type=zygote --no-sandbox pi 15311 8.2 10.3 337372 97832 ? Sl 13:55 2:52 /home/pi/MagicMirror/node_modules/electron/dist/electron --type=renderer --autoplay-policy=no-user-gesture-required --no-sandbox --service-pipe-token=E75C637B69C4371629AED884ECD5DCA7 --lang=en-US --app-path=/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar --node-integration=false --webview-tag=false --no-sandbox --background-color=#000000 --num-raster-threads=2 --enable-main-frame-before-activation --enable-compositor-image-animations --service-request-channel-token=E75C637B69C4371629AED884ECD5DCA7 --renderer-client-id=3 --shared-files=v8_context_snapshot_data:100,v8_natives_data:101 pi 15546 0.0 0.0 4372 572 pts/0 S+ 14:30 0:00 grep --color=auto node
etc
-
ps --help a
will show all the options for listing running processes