• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Command line to stop MM

Scheduled Pinned Locked Moved Solved Troubleshooting
11 Posts 3 Posters 9.0k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    l951b951
    last edited by Feb 3, 2020, 4:00 PM

    I have successfully created my config.js file and MM works from the terminal when I type

    npm start
    

    Is there a command to stop MM from the command line?

    S 1 Reply Last reply Feb 3, 2020, 7:38 PM Reply Quote 0
    • B Offline
      BKeyport Module Developer
      last edited by Feb 3, 2020, 5:19 PM

      npm stop

      The "E" in "Javascript" stands for "Easy"

      1 Reply Last reply Reply Quote 0
      • L Offline
        l951b951
        last edited by Feb 3, 2020, 5:30 PM

        It says “Missing Script: stop”

        1 Reply Last reply Reply Quote 0
        • B Offline
          BKeyport Module Developer
          last edited by Feb 3, 2020, 7:36 PM

          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.

          The "E" in "Javascript" stands for "Easy"

          1 Reply Last reply Reply Quote 0
          • S Away
            sdetweil @l951b951
            last edited by sdetweil Feb 3, 2020, 7:58 PM Feb 3, 2020, 7:38 PM

            @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

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            L 1 Reply Last reply Feb 3, 2020, 8:05 PM Reply Quote 0
            • L Offline
              l951b951
              last edited by Feb 3, 2020, 7:50 PM

              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.

              1 Reply Last reply Reply Quote 0
              • L Offline
                l951b951 @sdetweil
                last edited by Feb 3, 2020, 8:05 PM

                @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
                
                S 1 Reply Last reply Feb 3, 2020, 8:08 PM Reply Quote 0
                • S Away
                  sdetweil @l951b951
                  last edited by Feb 3, 2020, 8:08 PM

                  @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)

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • L Offline
                    l951b951
                    last edited by Feb 3, 2020, 8:22 PM

                    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?

                    S 1 Reply Last reply Feb 3, 2020, 8:31 PM Reply Quote 0
                    • S Away
                      sdetweil @l951b951
                      last edited by sdetweil Feb 3, 2020, 8:35 PM Feb 3, 2020, 8:31 PM

                      @l951b951

                      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

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 1
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        1/11
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy