No internet connection
  1. Home
  2. General

How to best schedule a weekly or nightly reboot for performance?

By @Alt0
    2022-01-18 20:13:01.205Z2022-01-18 20:23:33.262Z

    Hi there. I noticed that after about a week being connected and up and running to an always-on system that tiny pilot needs to be power cycled in order to maintain its snappy and responsive performance. Otherwise, things slow to a crawl when trying to remotely interact with the mouse, and having many seconds of delay in when moving around Windows etc (note it’s for sure not the slave OS or PC).

    Is there a way to add some automation like a scheduled task (in Windows) via some command to weekly or nightly reboot it via some command(s)? I know that “systemclt reboot -i” forces a reboot, but can I place that command somewhere or use something like “crontab” command here — https://linuxhint.com/schedule_linux_task/

    I’m a bit of a Linux noob so I would prefer if an expert or Michael could chime in with a starting point / script as an exmaple , and confirm this shouldn’t cause issues overtime (to constantly force restarts, that is)

    And yes, I know this would need to be reapplied after any future update.

    Thanks for the help!

    ps, I suppose the larger question at hand is why it does this. Could just be normal OS operation if other people notice this too after uStreamer being running for so long, or perhaps because I installed a lxde shell (tho it’s not running / initialized AFAIK). “htop” also doesn’t reveal much other than the many Stresming processes, but perhaps I can look closer over the various times it happens and try to connect the dots with what’s normal and what’s not from snapshots. In Many cases I just pull the power plug tho, because of the annoying behavior and I need it to work then an now.

    • 5 replies
    1. A
      @Alt0
        2022-01-19 07:38:00.235Z2022-01-19 21:34:11.279Z

        FYI -- I was able to get it. Posting to help others if needed.

        The following commands are executed as a root-sshed user, thus did not include sudo prepended.

        1. Change the timezone:
          cp /etc/localtime /etc/localtime.bkp
          rm /etc/localtime
          ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
          timedatectl
          service cron restart

        2. Edit the System cron tab:
          crontab -e => 1 (for nano). Only need to do that once

        3. To run on Sundays (6) at 11pm (00 23) the syntax would be as follows to restart uStreamer (could also put the command in a .sh script and specify the full path)
          00 23 * * 6 sudo service ustreamer restart
          OR
          As per the original ask: 00 23 * * 6 /sbin/shutdown -r now (notice that the cmd requires full file path for many bins/executes, tho 'systemctl' appears to work fine without any full path)

          • Ctrl + O to save
          • [Enter] for the random file it shows
          • Ctrl + X to exit. Now ensure it shows "crontab: installing new crontab" and not an error
        4. Setup cron job monitoring:
          Edit the file "/etc/default/cron" like in root-enabled WinSCP or via a 'sudo nano /etc/default/cron' to add this line : set EXTRA_OPTS="-L 2"
          service cron restart
          Then, in a dedicated SSH window have the log be monitored:
          tail -f /var/log/syslog

        5. The job should run. To test it, change the time to something like in the next minute: 01 * * * * [cmd] OR right now * * * * * [cmd]

        6. Once uStreamer is restarted, this requires a browser refresh / F5

        -- Links that helped me --

        Crontab Syntax : https://www.hostinger.com/tutorials/cron-job
        Cron job monitoring & overall troubleshooting : https://stackoverflow.com/a/22744360
        Timezone changing: https://askubuntu.com/a/582898

        1. Thanks for sharing this solution, @Alt0 !

          I'll see if I can find out why performance gets sluggish over time, as the ideal solution would be that you don't need this workaround at all.

          For this line:

          00 23 * * 6 systemctl daemon-reload && sudo service ustreamer restart

          You shouldn't need the systemctl daemon-reload part.

          1. A@Alt0
              2022-01-19 21:33:54.667Z

              Thanks!

              Guess that was some copypasta from another post :D

          2. J
            In reply toAlt0:
            jsas @jsas75
              2024-07-17 18:36:50.691Z

              Use a smart plug and set a schedule.

              1. Thanks for the suggestion, jsas. However, we must advise against using a smart outlet to control whether a TinyPilot device is powered on, as cutting the power supply without performing a safe shutdown can significantly increase the risk of filesystem corruption. Using cron to schedule a reboot is more reliable and should be safer.