The place I work at has commands that take a long time to execute.
Is there a command/utility that I can use to notify me when the command execution is over? It could be a popup window or maybe a little sound.
Generally, if you know this before running the command, you can just start it with:
This will execute the
If you care about a successful or failure exit, respectively use:
If the command has already started you may use job control to suspend it, then return it to the foreground with
Now … what you want to do after this depends on your environment.
I create a simple tool that does exactly this. https://github.com/vikfroberg/brb
I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.
For Linux, there is a nifty trick to do this automatically without having to type a command for notification every time.
First install autokey. This helps defining actions for different keystrokes.
Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:
Note that a new line after the first line is important.
Also, add a window filter. I use guake and terminal. Include whatever other terminal you use.
Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.
Although other answers already covered most of the ways to get notifications on a finished job, I want to give my two cents since you asked your question in the following format:
I have the same problem. Sometimes something can run for 15 minutes.
I have the following function in my .bashrc:
This uses the Pushover app in order to push a notification to my phone. This way I can go to lunch or enter a meeting and still get notified on jobs I started on my computer before I left.
I use it in the following manner:
So, if the command returns a correct exit code, the first push will be executed. On an error, the second one will be executed.
Ofc you need to create a user at Pushover, and register an app to send notifications from https://pushover.net/
hope this helped!
If you use csh or tcsh as your interactive shell, you can use the
You can achieve a similar effect in bash with
This probably doesn't meet your requirements, since all it does is print a message; I dont' think it can be configured to pop up a window or ring the bell.
On systems with 'awk' try
was the only one to work for me.