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.

    Help with Crontab starting pm2 mm.sh

    Scheduled Pinned Locked Moved Solved Troubleshooting
    8 Posts 2 Posters 478 Views 2 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.
    • D Offline
      DDE12
      last edited by

      I am using Rasp Pi Bookworm on a Libre Sweet Potato.
      In my user Crontab:
      29 14 * * * pm2 start mm.sh >/dev/null >2&1

      sweetpotatopi:~ $ sudo systemctl status cron
      ● cron.service - Regular background program processing daemon
           Loaded: loaded (/lib/systemd/system/cron.service; enabled; preset: enabled)
           Active: active (running) since Mon 2025-02-03 14:27:37 EST; 1min 55s ago
             Docs: man:cron(8)
         Main PID: 2402 (cron)
            Tasks: 1 (limit: 1986)
           Memory: 368.0K
              CPU: 165ms
           CGroup: /system.slice/cron.service
                   └─2402 /usr/sbin/cron -f
      
      Feb 03 14:27:37 sweetpotatopi systemd[1]: Started cron.service - Regular background program processing daemon.
      Feb 03 14:27:37 sweetpotatopi cron[2402]: (CRON) INFO (pidfile fd = 3)
      Feb 03 14:27:37 sweetpotatopi cron[2402]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
      Feb 03 14:29:01 sweetpotatopi CRON[2409]: pam_unix(cron:session): session opened for user user(uid=1000) by (uid=0)
      Feb 03 14:29:01 sweetpotatopi CRON[2410]: (user) CMD (pm2 start mm.sh >/dev/null >2&1)
      Feb 03 14:29:01 sweetpotatopi CRON[2409]: pam_unix(cron:session): session closed for user user
      
      

      But, the mirror is not starting.

      ~ $ pm2 show mm
       Describing process with id 0 - name mm 
      ┌───────────────────┬────────────────────────────────────┐
      │ status            │ stopped                            │
      │ name              │ mm                                 │
      │ namespace         │ default                            │
      │ version           │ N/A                                │
      │ restarts          │ 0                                  │
      │ uptime            │ 0                                  │
      │ script path       │ /home/user/mm.sh                  │
      │ script args       │ N/A                                │
      │ error log path    │ /home/user/.pm2/logs/mm-error.log │
      │ out log path      │ /home/user/.pm2/logs/mm-out.log   │
      │ pid path          │ /home/user/.pm2/pids/mm-0.pid     │
      │ interpreter       │ bash                               │
      │ interpreter args  │ N/A                                │
      │ script id         │ 0                                  │
      │ exec cwd          │ /home/user                        │
      │ exec mode         │ fork_mode                          │
      │ node.js version   │ N/A                                │
      │ node env          │ N/A                                │
      │ watch & reload    │ ✘                                  │
      │ unstable restarts │ 0                                  │
      │ created at        │ 2025-01-30T12:31:59.717Z           │
      └───────────────────┴────────────────────────────────────┘
       Divergent env variables from local env 
      ┌────────────────┬──────────────────────────────────┐
      │ _LXSESSION_PID │ 1234                             │
      │ SSH_AUTH_SOCK  │ /tmp/ssh-rK5CMznThwsE/agent.1234 │
      │ SSH_AGENT_PID  │ 1326                             │
      └────────────────┴──────────────────────────────────┘
      
      

      What do I have wrong? Thank you for taking a look at this.

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

        @sdetweil That was the solution. Thank you!

        29 14 * * * /usr/local/bin/pm2 start mm.sh >/dev/null >2&1
        
        S 1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil @DDE12
          last edited by

          @DDE12 anotgeruser had trouble, turned out he needed the full path to pm2

          which pm2
          

          Should give you that path

          Sam

          How to add modules

          learning how to use browser developers window for css changes

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

            @sdetweil That was the solution. Thank you!

            29 14 * * * /usr/local/bin/pm2 start mm.sh >/dev/null >2&1
            
            S 1 Reply Last reply Reply Quote 0
            • D DDE12 has marked this topic as solved on
            • S Offline
              sdetweil @DDE12
              last edited by

              @DDE12 and you don’t need start mm.sh

              After you’ve done it once

              pm2 status

              Will show the apps

              Name and row number

              You can use name or row number

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • D Offline
                DDE12
                last edited by DDE12

                Now I have

                PATH=/usr/local/bin:/usr/bin:/bin
                00 7 * * * pm2 start mm >/dev/null 2>&1
                
                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @DDE12
                  last edited by sdetweil

                  @DDE12 awesome!!

                  i learned recently that

                  &> xxx

                  is the same as >xxx 2>&1

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

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

                    @sdetweil Like so

                    PATH=/usr/local/bin:/usr/bin:/bin
                    00 7 * * * pm2 start mm &>/dev/null
                    
                    
                    S 1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil @DDE12
                      last edited by

                      @DDE12 yes

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • S sdetweil referenced this topic on
                      • 1 / 1
                      • 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