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

pm2 doesnt work with crontab

Scheduled Pinned Locked Moved Troubleshooting
27 Posts 6 Posters 6.2k Views 5 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.
  • S Away
    sdetweil @plainbroke
    last edited by sdetweil Jan 25, 2025, 10:24 PM Jan 25, 2025, 9:44 PM

    @plainbroke i mean after cron trying to start
    pm2

    set a cron entry for an hour from now stop MagicMirror and flush the logs

    pm2 stop all
    pm2 flush

    see what the logs say then

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    P 1 Reply Last reply Jan 26, 2025, 2:24 AM Reply Quote 0
    • S Away
      sdetweil @karsten13
      last edited by Jan 25, 2025, 10:23 PM

      @karsten13 yes, but he wants stop and start

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • P Offline
        plainbroke @sdetweil
        last edited by plainbroke Jan 26, 2025, 7:50 PM Jan 26, 2025, 2:24 AM

        @sdetweil
        Got ya, I miss understood before.
        Running and waiting for results now…

        Finally got results useing the proper path.
        @sdetweil
        You can mark this resolved.

        Slow learner. But trying anyways.

        S 1 Reply Last reply Jan 26, 2025, 2:56 AM Reply Quote 1
        • S Away
          sdetweil @plainbroke
          last edited by Jan 26, 2025, 2:56 AM

          @plainbroke how long til it might trigger?

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          P 1 Reply Last reply Jan 26, 2025, 2:21 PM Reply Quote 0
          • P Offline
            plainbroke @sdetweil
            last edited by Jan 26, 2025, 2:21 PM

            @sdetweil
            From that post about an hour. and it was supposed to trigger this morning around 6:30 am.
            It did not and it did not leave anything in the logs since last night when I pm2 stop all then pm2 flush. around 8:30 pm .
            So that means cron job did nothing with pm2 over night
            I have been experimenting so there are a couple different job lines.
            I really expected something in the log. But this is all I get.

            pi@MM:~ $ pm2 logs --lines=100
            [TAILING] Tailing last 100 lines for [all] processes (change the value with --lines option)
            /home/pi/.pm2/pm2.log last 100 lines:
            /home/pi/.pm2/logs/mm-out.log last 100 lines:
            /home/pi/.pm2/logs/mm-error.log last 100 lines:
            

            My Crontab on 2 different MM setups. I get the same nothing on both.
            Both are running Bookworm and MM 2.3.1

            05 20 * * * pi /usr/local/bin/pm2 start mm
            15 07 * * * pi pm2 start mm
            30 21 * * * pi pm2 stop mm
            05 20 * * * root /usr/local/bin/pm2 start mm
            15 07 * * * root pm2 start mm
            30 21 * * * root pm2 stop mm
            

            Slow learner. But trying anyways.

            C 1 Reply Last reply Jan 26, 2025, 4:08 PM Reply Quote 0
            • C Offline
              chrisfr1976 @plainbroke
              last edited by chrisfr1976 Jan 26, 2025, 4:16 PM Jan 26, 2025, 4:08 PM

              @plainbroke

              Hi,

              try this:

              crontab -e with connected user:

              05 20 * * * /usr/bin/pm2 start mm
              15 07 * * * /usr/bin/pm2 start mm
              30 21 * * * /usr/bin/pm2 stop mm
              
              • sudo crontab -e is not necessary.
              • I do not understand the start at 20:05 (first line)
              • my pm2 is in /usr/bin
              • always use full path in crontab

              If you’re not sure where PM2 is you can use find / -iname pm2 in the console. Important is the full path in crontab.
              /home/chris/.nvm/versions/node/v22.9.0/lib/node_modules/pm2/pm2 would be an alternative for me.

              Regards, Chris.

              P 1 Reply Last reply Jan 26, 2025, 5:44 PM Reply Quote 0
              • P Offline
                plainbroke @chrisfr1976
                last edited by plainbroke Jan 26, 2025, 5:47 PM Jan 26, 2025, 5:44 PM

                @chrisfr1976 said in pm2 doesnt work with crontab:

                find / -iname pm2

                /usr/local/bin/pm2
                /usr/local/lib/node_modules/pm2
                /usr/local/lib/node_modules/pm2/bin/pm2
                /usr/local/lib/node_modules/pm2/lib/templates/logrotate.d/pm2
                /usr/local/lib/node_modules/pm2/pm2
                
                
                /home/pi/MagicMirror/node_modules/.bin/pm2
                /home/pi/MagicMirror/node_modules/pm2
                /home/pi/MagicMirror/node_modules/pm2/bin/pm2
                /home/pi/MagicMirror/node_modules/pm2/lib/templates/logrotate.d/pm2
                /home/pi/MagicMirror/node_modules/pm2/pm2
                
                

                Which is the true one and one to use?

                Slow learner. But trying anyways.

                C 1 Reply Last reply Jan 26, 2025, 6:36 PM Reply Quote 0
                • C Offline
                  chrisfr1976 @plainbroke
                  last edited by Jan 26, 2025, 6:36 PM

                  @plainbroke
                  Then use this:
                  /usr/local/bin/pm2

                  Regards, Chris.

                  P 1 Reply Last reply Jan 26, 2025, 7:32 PM Reply Quote 1
                  • P Offline
                    plainbroke @chrisfr1976
                    last edited by plainbroke Jan 26, 2025, 7:57 PM Jan 26, 2025, 7:32 PM

                    @chrisfr1976
                    @sdetweil
                    Thank you both for the help.
                    /usr/local/bin/pm2 restart mm
                    worked so I set it up to stop now and if (fingers crossed) works.
                    I am golden.
                    Wonder why I never had to use the full path before?
                    Maybe my pm2 path was /home/pi/pm2 before.
                    Doesn’t really matter as long as it works, I am a happy camper.
                    It works.
                    Thank you so much… I will mark this solved.
                    Well I would if I could… strange.

                    By the way " which pm2 " shows the path that I needed to use in crontab -e

                    Slow learner. But trying anyways.

                    S 1 Reply Last reply Jan 26, 2025, 9:09 PM Reply Quote 1
                    • S Away
                      sdetweil @plainbroke
                      last edited by sdetweil Jan 26, 2025, 9:36 PM Jan 26, 2025, 9:09 PM

                      @plainbroke awesome

                      i should have remembered the path problem

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 1
                      • 1
                      • 2
                      • 3
                      • 3 / 3
                      3 / 3
                      • First post
                        22/27
                        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