How can I alert on completion of a long task over ssh?
6
votes
4
answers
4479
views
My desktop is Ubuntu, which has the handy program
notify-send
, which pops up an alert on the desktop. It also has the following handy alias built in:
$ type alert
alert is aliased to `notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e 's/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//')"'
This means that you can run very-long-running-command; alert
, leave the terminal running in the background, and receive a notification when the task is complete.
When you’re on a CentOS server through ssh, things are a little trickier. Here’s one way to do it:
localhost$ ssh me@example.net; alert
example.net$ very-long-running-command; exit
This works, after a fashion, but exiting after every command is not generally what I want to do.
My computer doesn’t have speakers. It can beep.
Asked by TRiG
(331 rep)
Apr 3, 2015, 02:58 PM
Last activity: Apr 30, 2025, 08:53 AM
Last activity: Apr 30, 2025, 08:53 AM