• 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.

Starting MM Crontab

Scheduled Pinned Locked Moved Bug Hunt
15 Posts 3 Posters 1.6k 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.
  • M Offline
    mumblebaj Module Developer
    last edited by Jul 3, 2025, 2:00 PM

    Hi.

    I have been using crontab to start my MM for ages and it has always worked well. After updating it no longer seems to work. cron calls a script that has the following.

    cd ~/MagicMirror
    DISPLAY=0 npm start
    

    Now, I have seen that it is suggest to use node --run start:X11 going forward and I have updated my start script with same but that does not seem to work either.

    So my mm.sh now looks like,

    cd ~/MagicMirror
    DISPLAY=0 node --run start:X11
    

    But as mentioned, this does not work.

    Any ideas?

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

    K 1 Reply Last reply Jul 3, 2025, 2:10 PM Reply Quote 0
    • K Offline
      KristjanESPERANTO Module Developer @mumblebaj
      last edited by KristjanESPERANTO Jul 3, 2025, 2:10 PM Jul 3, 2025, 2:10 PM

      @mumblebaj said in Starting MM Crontab:

      DISPLAY=0 node --run start:X11

      It should be start:x11 and not start:X11.

      Are you still using X11?

      Does it run when you start it manually?

      Can you provide the logs from the startup?

      M 1 Reply Last reply Jul 3, 2025, 2:17 PM Reply Quote 0
      • M Offline
        mumblebaj Module Developer @KristjanESPERANTO
        last edited by Jul 3, 2025, 2:17 PM

        @KristjanESPERANTO Sorry, typo, it is lower x. It start when I manually run npm start. When I manually run node --run start:x11 it works fine. When I manually run the script ./mm.sh it works fine. When calling it from the cron nothing. In my log I see the command node --run start:x11 but MM does not launch.

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

        S 1 Reply Last reply Jul 3, 2025, 2:24 PM Reply Quote 0
        • S Offline
          sdetweil @mumblebaj
          last edited by Jul 3, 2025, 2:24 PM

          @mumblebaj is the cron jon in the user crontab (contrab -e) ? or root (sudo crontab -e) ?

          if root, the pm2 job doesn’t exist there, it opnly exists under user who created the pm2 job

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          M 1 Reply Last reply Jul 3, 2025, 2:25 PM Reply Quote 0
          • M Offline
            mumblebaj Module Developer @sdetweil
            last edited by mumblebaj Jul 3, 2025, 2:26 PM Jul 3, 2025, 2:25 PM

            @sdetweil in my user, crontab -e. It worked just fine until I updated my mirror this morning. I don’t use pm2 on my installation for my own reasons… 😉

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

            S 1 Reply Last reply Jul 3, 2025, 2:36 PM Reply Quote 0
            • S Offline
              sdetweil @mumblebaj
              last edited by Jul 3, 2025, 2:36 PM

              @mumblebaj said in Starting MM Crontab:

              It worked just fine until I updated my mirror this morning.

              only MM update?

              note that we changed the startup strings.

              “start”: “node --run start:x11”,

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              M 1 Reply Last reply Jul 3, 2025, 2:39 PM Reply Quote 0
              • M Offline
                mumblebaj Module Developer @sdetweil
                last edited by Jul 3, 2025, 2:39 PM

                @sdetweil Yep, only MM update. Let me try start: node --run start:x11 and see what happens.

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

                K 1 Reply Last reply Jul 3, 2025, 10:05 PM Reply Quote 0
                • K Offline
                  KristjanESPERANTO Module Developer @mumblebaj
                  last edited by KristjanESPERANTO Jul 4, 2025, 6:02 AM Jul 3, 2025, 10:05 PM

                  @mumblebaj Just an idea: Maybe the node version used in Cron could be to old. When you run a script manually in your terminal, your full user environment (including things like .bashrc or .zshrc) is loaded. Cron runs in a much more minimal environment — it often doesn’t load your shell config files, so tools like nvm (Node Version Manager) might not be available.

                  How to fix it:

                  • Use the full path to Node: Find it with which node and use that path in your cron job.
                  • Set the environment manually in cron: You can define your PATH at the top of the cron file.
                  • Source nvm in your script: If you use nvm, add source ~/.nvm/nvm.sh and nvm use <version> before calling node.
                  M 1 Reply Last reply Jul 4, 2025, 1:40 PM Reply Quote 1
                  • M Offline
                    mumblebaj Module Developer @KristjanESPERANTO
                    last edited by Jul 4, 2025, 1:40 PM

                    @KristjanESPERANTO Thanks Kristjan. But I don’t see how updating MM could cause this. I only updated MM with Sam’s upgrade script. Don’t see how that has changed anything with regards to how Crontab works. Maybe it is related to changing the launch to node --run start. I can see the command being fired in the log but it does not launch MM like it did before the upgrade.

                    Anyhow, I manually launch it for now till I find a suitable solution.

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

                    S 1 Reply Last reply Jul 4, 2025, 1:46 PM Reply Quote 0
                    • S Offline
                      sdetweil @mumblebaj
                      last edited by Jul 4, 2025, 1:46 PM

                      @mumblebaj did you use npm start before?

                      it ‘may’ be the path as @KristjanESPERANTO mentioned

                      so from the user command line do

                      which node

                      and use that result in the cron command

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      M 2 Replies Last reply Jul 4, 2025, 2:11 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        9/15
                        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