How to best schedule a weekly or nightly reboot for performance?
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.
- A@Alt0
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.
-
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 -
Edit the System cron tab:
crontab -e => 1 (for nano). Only need to do that once -
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
-
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 -
The job should run. To test it, change the time to something like in the next minute: 01 * * * * [cmd] OR right now * * * * * [cmd]
-
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- Michael Lynch @michael2022-01-19 19:31:40.275Z
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.
-
- J
- CCharles Hague @cghague2024-07-17 21:53:15.178Z
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.