johndbritton / teleport

Virtual KVM for macOS
GNU General Public License v2.0
785 stars 131 forks source link

Restarting via script or CLI #126

Closed AngryApples closed 2 years ago

AngryApples commented 2 years ago

Question

Teleport starts becoming unstable after various conditions, including time, network changes, and other unknown unknowns. What I would like to do is have a cron job to restart teleport every hour (for instance). My issue is that I cannot find the teleport process in the ps -edf command. I do see the process in Activity Monitor, but that does not help me from a scripting perspective. Opening the app from the CLI is very easy, i.e. open /Applications/teleport.app

Any advice would be greatly appreciated.

Thanks for a Life Saving tool!!

X25guru commented 2 years ago

ps -ax | grep teleport

killall teleport

works, so that's a start. You can't however just run the app from the cli, so that will require some research. Let us know what you come up with.

Applescript may be a better way to go, but I don't know how to schedule them to run.

tomads commented 2 years ago

You can try this AppleScript to restart teleport silently in the background:

tell application "Finder" try tell application "teleport" to quit repeat tell application "System Events" if "teleport" is not in (name of application processes) then exit repeat end tell do shell script "sleep 0.5" end repeat delay 2 tell application "teleport" to activate end try end tell

Instead of a cron job, better try to create a launchagent (for your main library-folder) that runs the script every hour or so.

Alternatively, you can use an app like EventScripts (AppStore) that can launch the script every time the mac wakes up from sleep mode. The latter solved the problem for me ....

Good luck

Tom

AngryApples commented 2 years ago

These are great and have resolved my issue. Thank You!

X25guru commented 2 years ago

I don't want to restart teleport every hour; I'd find that pretty annoying if I was in the middle of working on something. I put the script in the menu bar and I can just run the app when things slow down. Beats having to move the keyboard to the slave machine to restart by a very wide margin. Thanks for the script.