Skip to content

Instantly share code, notes, and snippets.

@cirfi
Created June 10, 2017 06:44
Show Gist options
  • Save cirfi/4e2302c59c983d96ca83820cb156458c to your computer and use it in GitHub Desktop.
Save cirfi/4e2302c59c983d96ca83820cb156458c to your computer and use it in GitHub Desktop.
Tdesktop Auto Restarter
#!/bin/bash
for ((;;))
do
mem=$(ps -C telegram-desktop -o rss= | tail -1)
if ((!mem)); then
echo 'Starting Telegram Desktop...'
telegram-desktop &
sleep 300
continue
fi
echo 'Current Memory Usage: '$mem' KB'
if (($mem > '500000')); then
echo 'Restarting Telegram Desktop...'
killall telegram-desktop
telegram-desktop &
fi
sleep 300
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment