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 restart question (more of a linux question than MM)

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    4 Posts 2 Posters 14 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.
    • W Offline
      wyovino
      last edited by

      Hi,

      I’m trying to restart my mirror nightly with “pm2 restart mm” using a cron job. I’ve tried everything I can think of or find online but nothing works. I’ve created python and bash scripts, used the system crontab and the user crontab. I’ve tried it with and without “sudo” and also running it under the “pi” user. It always works interactively at the command line but not via crontab. Any suggestions?

      Also, I saw the warning post about the April 1st upgrade and Pi Zero W. Does that also apply to the Zero 2W?

      S 2 Replies Last reply Reply Quote 0
      • S Offline
        sdetweil @wyovino
        last edited by

        @wyovino using the user’s crontab from when the job was defined is the most important

        so

        crontab -e
        (no sudo)

        and then you would look in the /var/logs folder for the syslog file

        and should find a logs entry for the CRON task execution

        Mar  1 07:30:01 sams CRON[2992838]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
        Mar  1 07:30:01 sams CRON[2992839]: (sam) CMD (sshpass -f /home/sam/.idsync sudo rsync ....
        

        it might tell you what is happening to the prior cron jobs. (mine above is rsync just for demonstration)

        pm2 might already have cron support

        Using the --cron-restart Option
        This feature is used to ensure an application, which is intended to run continuously, is refreshed on a regular schedule. 
        Command Line:
        bash
        pm2 start xxxx --cron-restart "0 0 * * *"
        

        pm2 save

        Sam

        How to add modules

        learning how to use browser developers window for css changes

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

          @wyovino said:

          I saw the warning post about the April 1st upgrade and Pi Zero W

          no… pi02w is an armv7l processor, pi3 in pi0w physical shape…

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 1
          • W Offline
            wyovino @sdetweil
            last edited by wyovino

            @sdetweil

            Got it!

            In the user crontab:

            30 2 * * * /usr/local/bin/node /usr/local/bin/pm2 restart mm

            Restarts the mirror every day at 2:30 am local time.

            As always, thanks for your quick response!

            Bill

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 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