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.

    Stop and Start MM on a schedule

    Scheduled Pinned Locked Moved General Discussion
    13 Posts 4 Posters 1.7k Views 4 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.
    • plainbrokeP Offline
      plainbroke
      last edited by plainbroke

      How do I get MM to Start and Stop on a schedule?
      I am running Bookworm 64bit and MM v2.29
      This is what used to work in buster 32bit and MM v2.15
      in my crontab -e

      # Turn off display Sunday - Thursday at 21h45
      15 21 * * 0-4 pm2 stop all
      # Turn off display Friday - Saturday at 23h45
      45 21 * * 5,6 pm2 stop all
      # Turn on screen Monday - Friday at 7h00
      00 07 * * 1-5 pm2 start mm
      # Turn on screen Saturday - Sunday at 8h00
      00 08 * * 6,0 pm2 start mm
      

      It doesnt work anymore.
      Can someone explain why it doesnt work anymore and how to fix it.

      Slow learner. But trying anyways.

      S D 3 Replies Last reply Reply Quote 0
      • S Offline
        sdetweil @plainbroke
        last edited by sdetweil

        @plainbroke cron typically runs as root, but the pm2 info was saved under some user

        you can specify the username in crontab somehow

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        S 1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil @sdetweil
          last edited by

          @plainbroke see
          https://serverfault.com/questions/352835/crontab-running-as-a-specific-user

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @plainbroke
            last edited by

            @plainbroke does pm2 launch from cron?

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • D Offline
              DarrenO 0 @plainbroke
              last edited by

              @plainbroke Are you running from a Pi?
              I used to have scheduled on/off times like this and I used to turn on/off the HDMI port of the Pi at the specified times.
              As the screen I had it attached to no longer detected an output source, it would then go into sleep mode until the assigned time the script enabled the HDMI interface again.

              I don’t recall the actual command/settings I used to do it, but it was similar to :
              // To turn off
              xrandr --output HDMI-1 --off
              //to turn on.
              xrandr --output HDMI-1 --auto

              mumblebajM 1 Reply Last reply Reply Quote 0
              • mumblebajM Offline
                mumblebaj Module Developer @DarrenO 0
                last edited by mumblebaj

                @DarrenO-0 I would suggest having a look at the following post I created. I use it to turn my monitor on and off at scheduled times. Not restarting the Pi though.

                https://forum.magicmirror.builders/topic/19116/having-trouble-with-screen-on-and-off-here-are-some-tips-that-could-help?_=1735999238062

                Check out my modules at: https://github.com/mumblebaj?tab=repositories

                plainbrokeP 1 Reply Last reply Reply Quote 0
                • plainbrokeP Offline
                  plainbroke @mumblebaj
                  last edited by

                  @mumblebaj
                  Not wanting to turn off the screen, simply because it is a pain to reach the power button to turn it back on, and no remote to get into setup of the TV it was a $40 used tv I bought. it works but I just leave it on and stop MM with a black screen and and the bar in black with bright green letters. It is very very dim. I am going to add the
                  user pi and the path home/pi to the cron job and see what happens.

                  Thanks for the links
                  All of you.

                  @sdetweil
                  not sure yet if pm2 is working in cron?
                  hoping the change will work.

                  Slow learner. But trying anyways.

                  plainbrokeP S 2 Replies Last reply Reply Quote 0
                  • plainbrokeP Offline
                    plainbroke @plainbroke
                    last edited by

                    @DarrenO-0
                    @mumblebaj
                    @sdetweil
                    Is there a way to run a cron job?
                    I have done a few google searches with no results that worked.

                    Slow learner. But trying anyways.

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil @plainbroke
                      last edited by

                      @plainbroke said in Stop and Start MM on a schedule:

                      not sure yet if pm2 is working in cron?

                      has to be run as user that stored the config,. when pm2 save is done
                      cause that info is store in the users .pm2 folder, ~/.pm2

                      so if the cron job runs as user… oops…

                      so you might be able to use this, a trick I have in another app…

                      user=????username????
                      sudo -u $user pm2 start app_name or number
                      

                      this lets you sneak into user mode for one command

                      so my username is sam,
                      for example, stop my mm app

                      sudo -u sam pm2 stop 7  
                      

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      plainbrokeP 1 Reply Last reply Reply Quote 0
                      • plainbrokeP Offline
                        plainbroke @sdetweil
                        last edited by

                        @sdetweil
                        I think adding the user pi /home/pi/pm2 stop all
                        worked but I am using your update script right now.
                        So not sure which one stopped MagicMirror.
                        The dang mouse arrow is on the screen, so I will have to find that command to hide it now…

                        Slow learner. But trying anyways.

                        S 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 1 / 2
                        • First post
                          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