Get notified when remote task ends

Moa Raji
Moa Raji
Jul 20, 2017 · 1 min read
A notification coming back to the local machine, when a remote process ends.

So most of the time, I deal with a lot of remote programs that run for an annoying amount of time (e.g. 2 minutes or 5 minutes). The most annoying thing is that I end up wasting more than say 2 minutes on something else, waiting for the program to end, simply because I’m not notified about the process finishing.

There are many ways out there to get notified when a job ends. Some send you an email, which in my opinion is overkill for small programs that don’t take hours. Here’s my version (tested on Ubuntu):

alias notify=$'ssh <username>@$(echo $SSH_CLIENT | awk {\'print $1\'}) \'export DISPLAY=":0"; notify-send -t 30000 "Done"; \''

Basically, it’s ssh-ing back to your machine, and calling the notify-send command.

You can copy this into your .bashrc and replace <username> with your local machine’s username. Of course you need to have enabled incoming SSH. Here’s how to do that in Ubuntu.

Now to use it, you just add notify to the end of your programs. For example:

> ./long_program.sh; notify; 

When the remote program ends, you get a notification popup on your machine that says “Done”!

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade