How can I trigger a notification when a job/process ends?
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.
command-line unix process notifications
add a comment |
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.
command-line unix process notifications
1
@slhck's accepted answer is cool - I should have realized thatfg;say "Job finished"
would work. But... is there any way that it can be further automated - i.e. ring the bell or notify after completion of any job that takes more than a threshold like a minute? Is there a shell variable, e.g. in bash, that is elapsed time of the last command?
– Krazy Glew
Oct 26 '16 at 20:10
... 2 hours later, found stackoverflow.com/questions/1862510/… ... put '(( $timer_show > ${LONG_RUNTIME:-300} )) && say "long running job completed"' in timer_stop ... next, add to emacs' compile commands ... and notify my Pebble watch (I hate phone notifications)
– Krazy Glew
Oct 26 '16 at 22:59
add a comment |
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.
command-line unix process notifications
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.
command-line unix process notifications
command-line unix process notifications
edited Sep 28 '14 at 18:37
ᔕᖺᘎᕊ
5,25842441
5,25842441
asked Oct 11 '11 at 20:22
Utkarsh SinhaUtkarsh Sinha
68211117
68211117
1
@slhck's accepted answer is cool - I should have realized thatfg;say "Job finished"
would work. But... is there any way that it can be further automated - i.e. ring the bell or notify after completion of any job that takes more than a threshold like a minute? Is there a shell variable, e.g. in bash, that is elapsed time of the last command?
– Krazy Glew
Oct 26 '16 at 20:10
... 2 hours later, found stackoverflow.com/questions/1862510/… ... put '(( $timer_show > ${LONG_RUNTIME:-300} )) && say "long running job completed"' in timer_stop ... next, add to emacs' compile commands ... and notify my Pebble watch (I hate phone notifications)
– Krazy Glew
Oct 26 '16 at 22:59
add a comment |
1
@slhck's accepted answer is cool - I should have realized thatfg;say "Job finished"
would work. But... is there any way that it can be further automated - i.e. ring the bell or notify after completion of any job that takes more than a threshold like a minute? Is there a shell variable, e.g. in bash, that is elapsed time of the last command?
– Krazy Glew
Oct 26 '16 at 20:10
... 2 hours later, found stackoverflow.com/questions/1862510/… ... put '(( $timer_show > ${LONG_RUNTIME:-300} )) && say "long running job completed"' in timer_stop ... next, add to emacs' compile commands ... and notify my Pebble watch (I hate phone notifications)
– Krazy Glew
Oct 26 '16 at 22:59
1
1
@slhck's accepted answer is cool - I should have realized that
fg;say "Job finished"
would work. But... is there any way that it can be further automated - i.e. ring the bell or notify after completion of any job that takes more than a threshold like a minute? Is there a shell variable, e.g. in bash, that is elapsed time of the last command?– Krazy Glew
Oct 26 '16 at 20:10
@slhck's accepted answer is cool - I should have realized that
fg;say "Job finished"
would work. But... is there any way that it can be further automated - i.e. ring the bell or notify after completion of any job that takes more than a threshold like a minute? Is there a shell variable, e.g. in bash, that is elapsed time of the last command?– Krazy Glew
Oct 26 '16 at 20:10
... 2 hours later, found stackoverflow.com/questions/1862510/… ... put '(( $timer_show > ${LONG_RUNTIME:-300} )) && say "long running job completed"' in timer_stop ... next, add to emacs' compile commands ... and notify my Pebble watch (I hate phone notifications)
– Krazy Glew
Oct 26 '16 at 22:59
... 2 hours later, found stackoverflow.com/questions/1862510/… ... put '(( $timer_show > ${LONG_RUNTIME:-300} )) && say "long running job completed"' in timer_stop ... next, add to emacs' compile commands ... and notify my Pebble watch (I hate phone notifications)
– Krazy Glew
Oct 26 '16 at 22:59
add a comment |
15 Answers
15
active
oldest
votes
Generally, if you know this before running the command, you can just start it with:
command; command-after &
This will execute the command-after
after the previous command has exited (regardless of its exit code). The &
will start it in background.
If you care about a successful or failure exit, respectively use:
command && command-after-only-if-success &
command || command-after-only-if-fail &
If the command has already started you may use job control to suspend it, then return it to the foreground with fg
chained with your notification:
command
# enter Ctrl-z
fg ; command-after
Now … what you want to do after this depends on your environment.
On any system, you can "ring" the terminal bell. Depends on your exact system what really works (BSD vs. GNU Linux, etc.), but
tput bel
should do. I couldn't reliably test it right now, though. Search for "ring bell" to find out more.
On Mac OS X, you could use AppleScript to pop up a Finder dialog:
osascript -e 'tell Application "Finder" to display dialog "Job finished" '
You could have it say something to you:
say "Job finished"
Or you could use Mountain Lion's notification system:
sudo gem install terminal-notifier # <= only need to do this once
terminal-notifier -message "Job finished!" -title "Info"
In GNOME,
zenity
can show a GTK dialog box, called from the command line. See also this Stack Overflow question: showing a message box from a bash script in linux. It can be installed through your favorite package manager.
zenity --info --text="Job finished"
Some distributions might have
xmessage
. Specifically for GTK environments, there isgxmessage
.
Ubuntu has a notification system that you can trigger with
notify-send
.
notify-send "Job finished!"
KDE uses
kdialog
, for example:
kdialog --passivepopup 'Job finished'
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
2
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
1
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say(command; command-after) &
?
– G-Man
Jun 24 '15 at 3:13
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
|
show 2 more comments
On unix-like systems you can ring the audible-bell:
echo -e "a"
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
1
same astput bel
– Dwight Spencer
Sep 2 '15 at 18:31
add a comment |
I created a simple tool, for MacOS X, that does exactly this. https://github.com/vikfroberg/brb
Installation
$ npm install -g brb
Instructions
$ sleep 3; brb
add a comment |
I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.
Example:
ls -l && /c/notifu-1.6/notifu64 /m "This is a simple Notifu message."
add a comment |
To get a sound notification you can use spd-say "Some text"
. Example:
some-command; spd-say "Yo"
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
1
It is just a text-to-speech application. You can install it viasudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…
– milkovsky
Jul 26 '16 at 7:48
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
|
show 1 more comment
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.
sudo apt-get install autokey-gtk
Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:
; notify-send "Job finished!" &
#
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.
.*(guake)|(Terminal).*
You're done!!
Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.
Source: http://dotpad.blogspot.in/2014/12/notification-when-command-finished.html
add a comment |
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:
The place I work at has commands that take a long time to execute.
I have the same problem. Sometimes something can run for 15 minutes.
I have the following function in my .bashrc:
# push a notification to your phone. can be handy if you're running a
# build and you want to be notified when it's finished.
push() {
curl -s -F "token=PUSHOVER_TOKEN"
-F "user=PUSHOVER_USER"
-F "title=terminal"
-F "message=$1" https://api.pushover.net/1/messages.json > /dev/null 2>&1
}
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:
command_to_run && push "yes! command finished successfully!" || push "awww man! something failed :-("
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!
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
1
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
add a comment |
I wrote ntfy
for exactly this purpose. It is cross-platform and can automatically send notifications when long running commands finish.
If you have Python's pip
(most Linux distros and MacOS have it), here's how to install it and enable automatic notifications:
$ sudo pip install ntfy
$ echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
$ # restart your shell
Check it out at http://ntfy.rtfd.io
In addition to that, it also can:
- supress automatic notifications when the terminal is in the foreground (X11, iTerm2 & Terminal.app supported and enabled by default)
- send cloud-based notifications (Pushover, Pushbullet, and XMPP)
- be used to send notifications when a process ends (not the aforementioned automatic support)
- manually send notifications (good for use in scripts!)
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
add a comment |
If you use csh or tcsh as your interactive shell, you can use the notify
command:
% long-running-command &
[1] 14431
% notify %1
%
(later, when the command finishes)
[1] Done long-running-command
You can achieve a similar effect in bash with set -b
or set -o notify
.
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.
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
add a comment |
On systems with 'awk' try
awk 'BEGIN{ print "a" }'
was the only one to work for me.
1
That's just a verbose way of echoinga
(trinth's answer).
– David Richerby
Sep 4 '15 at 8:05
add a comment |
If you're using npm
then node-notifier provide a cross-platform solution.
notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg -m "Well, that's new. "
Preview
- Linux KDE
- Windows
- Mac OS
- Growl
add a comment |
Wish I'd noticed this thread years ago. My solution was essentially the same as slhck's, but I wrote a script. I use it all the time. Posting here to share it.
#!/bin/bash
msg='all done'
quiet=false
if [ "$1" = '-q' ]; then quiet=true; shift; fi
if [ $# -gt 0 ]; then msg="$*"; fi
echo -ne "x1b]0;$msga"
if [ -x /usr/bin/zenity ]; then
unset WINDOWID
exec zenity --info --text="$msg"
elif [ -x /usr/bin/xmessage ]; then
exec xmessage -nearmouse "$msg"
elif [ -x /usr/bin/osascript ]; then
if ! $quiet; then say "done" &; fi
osascript -e "tell application "System Events" to display dialog "$msg""
else
echo $msg
fi
One small bit of explanation: the string "x1b]0;$msga"
is the ANSI escape sequence to put the message in the title bar of the window from which it was executed. I find it quite handy sometimes to be able to see which window it was that the message came from.
add a comment |
So this comes fairly late, but I've started using a system to do this:
I have a bash script which executes whatever command is passed to it afterwards
http://somesh.io/2017/02/19/get-notified-when-long-commands-are-done-executing-on-ubuntu/
#!/bin/bash
# file location : /usr/bin/n
set +e
# $@ executes whatever command is typed after the filename
$@
notify-send "Task Completed"
and then i simply prepend n
n bundle install
n npm install
add a comment |
Another possibility is to use alert
, Works on Linux.
>any-command; alert
It gives a notification as in the image.
alert notification
add a comment |
I made an app that will send a notification to your Android phone when a process ends so you don't have to be tethered to your computer.
Install, then add ;notifier.sh
to the end of your command.
For example, if your command was make install
, you would make your command:
make install; notifier.sh
https://notifier.sh
https://play.google.com/store/apps/details?id=sh.notifier
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f345447%2fhow-can-i-trigger-a-notification-when-a-job-process-ends%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
15 Answers
15
active
oldest
votes
15 Answers
15
active
oldest
votes
active
oldest
votes
active
oldest
votes
Generally, if you know this before running the command, you can just start it with:
command; command-after &
This will execute the command-after
after the previous command has exited (regardless of its exit code). The &
will start it in background.
If you care about a successful or failure exit, respectively use:
command && command-after-only-if-success &
command || command-after-only-if-fail &
If the command has already started you may use job control to suspend it, then return it to the foreground with fg
chained with your notification:
command
# enter Ctrl-z
fg ; command-after
Now … what you want to do after this depends on your environment.
On any system, you can "ring" the terminal bell. Depends on your exact system what really works (BSD vs. GNU Linux, etc.), but
tput bel
should do. I couldn't reliably test it right now, though. Search for "ring bell" to find out more.
On Mac OS X, you could use AppleScript to pop up a Finder dialog:
osascript -e 'tell Application "Finder" to display dialog "Job finished" '
You could have it say something to you:
say "Job finished"
Or you could use Mountain Lion's notification system:
sudo gem install terminal-notifier # <= only need to do this once
terminal-notifier -message "Job finished!" -title "Info"
In GNOME,
zenity
can show a GTK dialog box, called from the command line. See also this Stack Overflow question: showing a message box from a bash script in linux. It can be installed through your favorite package manager.
zenity --info --text="Job finished"
Some distributions might have
xmessage
. Specifically for GTK environments, there isgxmessage
.
Ubuntu has a notification system that you can trigger with
notify-send
.
notify-send "Job finished!"
KDE uses
kdialog
, for example:
kdialog --passivepopup 'Job finished'
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
2
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
1
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say(command; command-after) &
?
– G-Man
Jun 24 '15 at 3:13
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
|
show 2 more comments
Generally, if you know this before running the command, you can just start it with:
command; command-after &
This will execute the command-after
after the previous command has exited (regardless of its exit code). The &
will start it in background.
If you care about a successful or failure exit, respectively use:
command && command-after-only-if-success &
command || command-after-only-if-fail &
If the command has already started you may use job control to suspend it, then return it to the foreground with fg
chained with your notification:
command
# enter Ctrl-z
fg ; command-after
Now … what you want to do after this depends on your environment.
On any system, you can "ring" the terminal bell. Depends on your exact system what really works (BSD vs. GNU Linux, etc.), but
tput bel
should do. I couldn't reliably test it right now, though. Search for "ring bell" to find out more.
On Mac OS X, you could use AppleScript to pop up a Finder dialog:
osascript -e 'tell Application "Finder" to display dialog "Job finished" '
You could have it say something to you:
say "Job finished"
Or you could use Mountain Lion's notification system:
sudo gem install terminal-notifier # <= only need to do this once
terminal-notifier -message "Job finished!" -title "Info"
In GNOME,
zenity
can show a GTK dialog box, called from the command line. See also this Stack Overflow question: showing a message box from a bash script in linux. It can be installed through your favorite package manager.
zenity --info --text="Job finished"
Some distributions might have
xmessage
. Specifically for GTK environments, there isgxmessage
.
Ubuntu has a notification system that you can trigger with
notify-send
.
notify-send "Job finished!"
KDE uses
kdialog
, for example:
kdialog --passivepopup 'Job finished'
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
2
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
1
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say(command; command-after) &
?
– G-Man
Jun 24 '15 at 3:13
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
|
show 2 more comments
Generally, if you know this before running the command, you can just start it with:
command; command-after &
This will execute the command-after
after the previous command has exited (regardless of its exit code). The &
will start it in background.
If you care about a successful or failure exit, respectively use:
command && command-after-only-if-success &
command || command-after-only-if-fail &
If the command has already started you may use job control to suspend it, then return it to the foreground with fg
chained with your notification:
command
# enter Ctrl-z
fg ; command-after
Now … what you want to do after this depends on your environment.
On any system, you can "ring" the terminal bell. Depends on your exact system what really works (BSD vs. GNU Linux, etc.), but
tput bel
should do. I couldn't reliably test it right now, though. Search for "ring bell" to find out more.
On Mac OS X, you could use AppleScript to pop up a Finder dialog:
osascript -e 'tell Application "Finder" to display dialog "Job finished" '
You could have it say something to you:
say "Job finished"
Or you could use Mountain Lion's notification system:
sudo gem install terminal-notifier # <= only need to do this once
terminal-notifier -message "Job finished!" -title "Info"
In GNOME,
zenity
can show a GTK dialog box, called from the command line. See also this Stack Overflow question: showing a message box from a bash script in linux. It can be installed through your favorite package manager.
zenity --info --text="Job finished"
Some distributions might have
xmessage
. Specifically for GTK environments, there isgxmessage
.
Ubuntu has a notification system that you can trigger with
notify-send
.
notify-send "Job finished!"
KDE uses
kdialog
, for example:
kdialog --passivepopup 'Job finished'
Generally, if you know this before running the command, you can just start it with:
command; command-after &
This will execute the command-after
after the previous command has exited (regardless of its exit code). The &
will start it in background.
If you care about a successful or failure exit, respectively use:
command && command-after-only-if-success &
command || command-after-only-if-fail &
If the command has already started you may use job control to suspend it, then return it to the foreground with fg
chained with your notification:
command
# enter Ctrl-z
fg ; command-after
Now … what you want to do after this depends on your environment.
On any system, you can "ring" the terminal bell. Depends on your exact system what really works (BSD vs. GNU Linux, etc.), but
tput bel
should do. I couldn't reliably test it right now, though. Search for "ring bell" to find out more.
On Mac OS X, you could use AppleScript to pop up a Finder dialog:
osascript -e 'tell Application "Finder" to display dialog "Job finished" '
You could have it say something to you:
say "Job finished"
Or you could use Mountain Lion's notification system:
sudo gem install terminal-notifier # <= only need to do this once
terminal-notifier -message "Job finished!" -title "Info"
In GNOME,
zenity
can show a GTK dialog box, called from the command line. See also this Stack Overflow question: showing a message box from a bash script in linux. It can be installed through your favorite package manager.
zenity --info --text="Job finished"
Some distributions might have
xmessage
. Specifically for GTK environments, there isgxmessage
.
Ubuntu has a notification system that you can trigger with
notify-send
.
notify-send "Job finished!"
KDE uses
kdialog
, for example:
kdialog --passivepopup 'Job finished'
edited May 23 '17 at 12:41
Community♦
1
1
answered Oct 11 '11 at 20:40
slhckslhck
163k47449473
163k47449473
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
2
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
1
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say(command; command-after) &
?
– G-Man
Jun 24 '15 at 3:13
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
|
show 2 more comments
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
2
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
1
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say(command; command-after) &
?
– G-Man
Jun 24 '15 at 3:13
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
Let me know what command you used! I added some other options as well.
– slhck
Oct 11 '11 at 20:54
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
I'm fiddling around with notify-send and xmessage. Both of them seem to be interesting! Here's the next thing I'm looking for - superuser.com/questions/345463/…
– Utkarsh Sinha
Oct 11 '11 at 21:04
2
2
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
on Mac OS X, you can also use the command-line utility "say". there are also many voices available, check "say -h" ;)
– trinth
Oct 10 '12 at 18:28
1
1
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say
(command; command-after) &
?– G-Man
Jun 24 '15 at 3:13
Why are you suggesting that "command-after" should be run asynchronously? Did you mean to say
(command; command-after) &
?– G-Man
Jun 24 '15 at 3:13
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
This solution is for Konsole users and isn't a perfect solution as it relies on your command either being verbose until it is complete, or completely silent (no output) until it completes at which point the prompt returns. However, this is exactly what I needed when I came looking for help. You can configure Konsole to pop-up a notification, play a sound, etc. Then you have to turn on shell monitoring. Monitor for silence if your command outputs a bunch of stuff until it completes, or silence if it doesn't print out anything and then the shell returns.
– MrMas
Nov 4 '15 at 22:56
|
show 2 more comments
On unix-like systems you can ring the audible-bell:
echo -e "a"
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
1
same astput bel
– Dwight Spencer
Sep 2 '15 at 18:31
add a comment |
On unix-like systems you can ring the audible-bell:
echo -e "a"
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
1
same astput bel
– Dwight Spencer
Sep 2 '15 at 18:31
add a comment |
On unix-like systems you can ring the audible-bell:
echo -e "a"
On unix-like systems you can ring the audible-bell:
echo -e "a"
answered Oct 10 '12 at 18:29
trinthtrinth
28924
28924
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
1
same astput bel
– Dwight Spencer
Sep 2 '15 at 18:31
add a comment |
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
1
same astput bel
– Dwight Spencer
Sep 2 '15 at 18:31
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
This is really useful in addition to a message notification on mac
– Sirens
Apr 1 '13 at 18:49
1
1
same as
tput bel
– Dwight Spencer
Sep 2 '15 at 18:31
same as
tput bel
– Dwight Spencer
Sep 2 '15 at 18:31
add a comment |
I created a simple tool, for MacOS X, that does exactly this. https://github.com/vikfroberg/brb
Installation
$ npm install -g brb
Instructions
$ sleep 3; brb
add a comment |
I created a simple tool, for MacOS X, that does exactly this. https://github.com/vikfroberg/brb
Installation
$ npm install -g brb
Instructions
$ sleep 3; brb
add a comment |
I created a simple tool, for MacOS X, that does exactly this. https://github.com/vikfroberg/brb
Installation
$ npm install -g brb
Instructions
$ sleep 3; brb
I created a simple tool, for MacOS X, that does exactly this. https://github.com/vikfroberg/brb
Installation
$ npm install -g brb
Instructions
$ sleep 3; brb
edited Jan 8 '16 at 11:44
Édouard Lopez
18010
18010
answered Jun 8 '14 at 10:43
Viktor FröbergViktor Fröberg
8111
8111
add a comment |
add a comment |
I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.
Example:
ls -l && /c/notifu-1.6/notifu64 /m "This is a simple Notifu message."
add a comment |
I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.
Example:
ls -l && /c/notifu-1.6/notifu64 /m "This is a simple Notifu message."
add a comment |
I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.
Example:
ls -l && /c/notifu-1.6/notifu64 /m "This is a simple Notifu message."
I have just begun using notifu for desktop notifications from Cygwin. It's a command line notification app for Windows.
Example:
ls -l && /c/notifu-1.6/notifu64 /m "This is a simple Notifu message."
answered Sep 13 '13 at 7:21
Ashutosh JindalAshutosh Jindal
305110
305110
add a comment |
add a comment |
To get a sound notification you can use spd-say "Some text"
. Example:
some-command; spd-say "Yo"
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
1
It is just a text-to-speech application. You can install it viasudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…
– milkovsky
Jul 26 '16 at 7:48
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
|
show 1 more comment
To get a sound notification you can use spd-say "Some text"
. Example:
some-command; spd-say "Yo"
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
1
It is just a text-to-speech application. You can install it viasudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…
– milkovsky
Jul 26 '16 at 7:48
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
|
show 1 more comment
To get a sound notification you can use spd-say "Some text"
. Example:
some-command; spd-say "Yo"
To get a sound notification you can use spd-say "Some text"
. Example:
some-command; spd-say "Yo"
edited Apr 20 '16 at 21:10
answered Dec 15 '15 at 17:54
milkovskymilkovsky
1916
1916
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
1
It is just a text-to-speech application. You can install it viasudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…
– milkovsky
Jul 26 '16 at 7:48
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
|
show 1 more comment
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
1
It is just a text-to-speech application. You can install it viasudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…
– milkovsky
Jul 26 '16 at 7:48
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
What OS? I don't see it on Mac or Ubuntu
– Edward Falk
Jul 24 '16 at 20:07
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
@EdwardFalk I am using Ubuntu
– milkovsky
Jul 25 '16 at 10:40
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
OK, I'm using a pretty old version, so maybe it's in newer versions.
– Edward Falk
Jul 25 '16 at 17:04
1
1
It is just a text-to-speech application. You can install it via
sudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…– milkovsky
Jul 26 '16 at 7:48
It is just a text-to-speech application. You can install it via
sudo apt-get install speech-dispatcher
. Or use alternatives askubuntu.com/questions/501910/…– milkovsky
Jul 26 '16 at 7:48
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
Ahh, not installed by default? I should have thought about that. Thanks for the link.
– Edward Falk
Jul 26 '16 at 16:54
|
show 1 more comment
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.
sudo apt-get install autokey-gtk
Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:
; notify-send "Job finished!" &
#
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.
.*(guake)|(Terminal).*
You're done!!
Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.
Source: http://dotpad.blogspot.in/2014/12/notification-when-command-finished.html
add a comment |
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.
sudo apt-get install autokey-gtk
Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:
; notify-send "Job finished!" &
#
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.
.*(guake)|(Terminal).*
You're done!!
Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.
Source: http://dotpad.blogspot.in/2014/12/notification-when-command-finished.html
add a comment |
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.
sudo apt-get install autokey-gtk
Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:
; notify-send "Job finished!" &
#
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.
.*(guake)|(Terminal).*
You're done!!
Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.
Source: http://dotpad.blogspot.in/2014/12/notification-when-command-finished.html
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.
sudo apt-get install autokey-gtk
Now, define a new phrase in autokey and assign the hotkey as Alt+Enter. Add this phrase:
; notify-send "Job finished!" &
#
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.
.*(guake)|(Terminal).*
You're done!!
Now, everytime whenever you need to get notifications for a command, run it using Alt+Enter instead of Enter/Return.
Source: http://dotpad.blogspot.in/2014/12/notification-when-command-finished.html
answered Dec 27 '14 at 12:39
shivamsshivams
1,02311023
1,02311023
add a comment |
add a comment |
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:
The place I work at has commands that take a long time to execute.
I have the same problem. Sometimes something can run for 15 minutes.
I have the following function in my .bashrc:
# push a notification to your phone. can be handy if you're running a
# build and you want to be notified when it's finished.
push() {
curl -s -F "token=PUSHOVER_TOKEN"
-F "user=PUSHOVER_USER"
-F "title=terminal"
-F "message=$1" https://api.pushover.net/1/messages.json > /dev/null 2>&1
}
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:
command_to_run && push "yes! command finished successfully!" || push "awww man! something failed :-("
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!
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
1
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
add a comment |
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:
The place I work at has commands that take a long time to execute.
I have the same problem. Sometimes something can run for 15 minutes.
I have the following function in my .bashrc:
# push a notification to your phone. can be handy if you're running a
# build and you want to be notified when it's finished.
push() {
curl -s -F "token=PUSHOVER_TOKEN"
-F "user=PUSHOVER_USER"
-F "title=terminal"
-F "message=$1" https://api.pushover.net/1/messages.json > /dev/null 2>&1
}
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:
command_to_run && push "yes! command finished successfully!" || push "awww man! something failed :-("
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!
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
1
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
add a comment |
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:
The place I work at has commands that take a long time to execute.
I have the same problem. Sometimes something can run for 15 minutes.
I have the following function in my .bashrc:
# push a notification to your phone. can be handy if you're running a
# build and you want to be notified when it's finished.
push() {
curl -s -F "token=PUSHOVER_TOKEN"
-F "user=PUSHOVER_USER"
-F "title=terminal"
-F "message=$1" https://api.pushover.net/1/messages.json > /dev/null 2>&1
}
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:
command_to_run && push "yes! command finished successfully!" || push "awww man! something failed :-("
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!
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:
The place I work at has commands that take a long time to execute.
I have the same problem. Sometimes something can run for 15 minutes.
I have the following function in my .bashrc:
# push a notification to your phone. can be handy if you're running a
# build and you want to be notified when it's finished.
push() {
curl -s -F "token=PUSHOVER_TOKEN"
-F "user=PUSHOVER_USER"
-F "title=terminal"
-F "message=$1" https://api.pushover.net/1/messages.json > /dev/null 2>&1
}
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:
command_to_run && push "yes! command finished successfully!" || push "awww man! something failed :-("
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!
answered Jun 23 '15 at 11:15
ThatkookooguyThatkookooguy
1366
1366
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
1
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
add a comment |
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
1
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
OK, so "pushover" is a web service that sends notifications to phones that have the "pushover" app installed?
– Edward Falk
Jul 24 '16 at 20:09
1
1
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
it's a web service that sends notifications to phones, computers, & everything with a modern web browser. So, you can have pushover open on your PC and phone and be notified on all devices. neat, huh? :-)
– Thatkookooguy
Jul 31 '16 at 7:53
add a comment |
I wrote ntfy
for exactly this purpose. It is cross-platform and can automatically send notifications when long running commands finish.
If you have Python's pip
(most Linux distros and MacOS have it), here's how to install it and enable automatic notifications:
$ sudo pip install ntfy
$ echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
$ # restart your shell
Check it out at http://ntfy.rtfd.io
In addition to that, it also can:
- supress automatic notifications when the terminal is in the foreground (X11, iTerm2 & Terminal.app supported and enabled by default)
- send cloud-based notifications (Pushover, Pushbullet, and XMPP)
- be used to send notifications when a process ends (not the aforementioned automatic support)
- manually send notifications (good for use in scripts!)
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
add a comment |
I wrote ntfy
for exactly this purpose. It is cross-platform and can automatically send notifications when long running commands finish.
If you have Python's pip
(most Linux distros and MacOS have it), here's how to install it and enable automatic notifications:
$ sudo pip install ntfy
$ echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
$ # restart your shell
Check it out at http://ntfy.rtfd.io
In addition to that, it also can:
- supress automatic notifications when the terminal is in the foreground (X11, iTerm2 & Terminal.app supported and enabled by default)
- send cloud-based notifications (Pushover, Pushbullet, and XMPP)
- be used to send notifications when a process ends (not the aforementioned automatic support)
- manually send notifications (good for use in scripts!)
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
add a comment |
I wrote ntfy
for exactly this purpose. It is cross-platform and can automatically send notifications when long running commands finish.
If you have Python's pip
(most Linux distros and MacOS have it), here's how to install it and enable automatic notifications:
$ sudo pip install ntfy
$ echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
$ # restart your shell
Check it out at http://ntfy.rtfd.io
In addition to that, it also can:
- supress automatic notifications when the terminal is in the foreground (X11, iTerm2 & Terminal.app supported and enabled by default)
- send cloud-based notifications (Pushover, Pushbullet, and XMPP)
- be used to send notifications when a process ends (not the aforementioned automatic support)
- manually send notifications (good for use in scripts!)
I wrote ntfy
for exactly this purpose. It is cross-platform and can automatically send notifications when long running commands finish.
If you have Python's pip
(most Linux distros and MacOS have it), here's how to install it and enable automatic notifications:
$ sudo pip install ntfy
$ echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
$ # restart your shell
Check it out at http://ntfy.rtfd.io
In addition to that, it also can:
- supress automatic notifications when the terminal is in the foreground (X11, iTerm2 & Terminal.app supported and enabled by default)
- send cloud-based notifications (Pushover, Pushbullet, and XMPP)
- be used to send notifications when a process ends (not the aforementioned automatic support)
- manually send notifications (good for use in scripts!)
answered May 19 '16 at 15:44
Daniel SchepDaniel Schep
311
311
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
add a comment |
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
Good on you. This is really the most usable answer.
– Adam Bittlingmayer
Aug 18 '17 at 9:43
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
I agree. I use it to display a notification on my desktop and push the notification to my phone at the same time.
– Michael
Dec 7 '17 at 20:30
add a comment |
If you use csh or tcsh as your interactive shell, you can use the notify
command:
% long-running-command &
[1] 14431
% notify %1
%
(later, when the command finishes)
[1] Done long-running-command
You can achieve a similar effect in bash with set -b
or set -o notify
.
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.
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
add a comment |
If you use csh or tcsh as your interactive shell, you can use the notify
command:
% long-running-command &
[1] 14431
% notify %1
%
(later, when the command finishes)
[1] Done long-running-command
You can achieve a similar effect in bash with set -b
or set -o notify
.
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.
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
add a comment |
If you use csh or tcsh as your interactive shell, you can use the notify
command:
% long-running-command &
[1] 14431
% notify %1
%
(later, when the command finishes)
[1] Done long-running-command
You can achieve a similar effect in bash with set -b
or set -o notify
.
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.
If you use csh or tcsh as your interactive shell, you can use the notify
command:
% long-running-command &
[1] 14431
% notify %1
%
(later, when the command finishes)
[1] Done long-running-command
You can achieve a similar effect in bash with set -b
or set -o notify
.
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.
answered Oct 11 '11 at 21:58
Keith ThompsonKeith Thompson
4,36721929
4,36721929
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
add a comment |
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
I'm trying to avoid looking at the shell to find out if a job finished. Thanks, though!
– Utkarsh Sinha
Oct 11 '11 at 22:20
add a comment |
On systems with 'awk' try
awk 'BEGIN{ print "a" }'
was the only one to work for me.
1
That's just a verbose way of echoinga
(trinth's answer).
– David Richerby
Sep 4 '15 at 8:05
add a comment |
On systems with 'awk' try
awk 'BEGIN{ print "a" }'
was the only one to work for me.
1
That's just a verbose way of echoinga
(trinth's answer).
– David Richerby
Sep 4 '15 at 8:05
add a comment |
On systems with 'awk' try
awk 'BEGIN{ print "a" }'
was the only one to work for me.
On systems with 'awk' try
awk 'BEGIN{ print "a" }'
was the only one to work for me.
answered Sep 4 '15 at 7:23
KrzysztofKrzysztof
112
112
1
That's just a verbose way of echoinga
(trinth's answer).
– David Richerby
Sep 4 '15 at 8:05
add a comment |
1
That's just a verbose way of echoinga
(trinth's answer).
– David Richerby
Sep 4 '15 at 8:05
1
1
That's just a verbose way of echoing
a
(trinth's answer).– David Richerby
Sep 4 '15 at 8:05
That's just a verbose way of echoing
a
(trinth's answer).– David Richerby
Sep 4 '15 at 8:05
add a comment |
If you're using npm
then node-notifier provide a cross-platform solution.
notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg -m "Well, that's new. "
Preview
- Linux KDE
- Windows
- Mac OS
- Growl
add a comment |
If you're using npm
then node-notifier provide a cross-platform solution.
notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg -m "Well, that's new. "
Preview
- Linux KDE
- Windows
- Mac OS
- Growl
add a comment |
If you're using npm
then node-notifier provide a cross-platform solution.
notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg -m "Well, that's new. "
Preview
- Linux KDE
- Windows
- Mac OS
- Growl
If you're using npm
then node-notifier provide a cross-platform solution.
notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg -m "Well, that's new. "
Preview
- Linux KDE
- Windows
- Mac OS
- Growl
answered Jan 8 '16 at 11:44
Édouard LopezÉdouard Lopez
18010
18010
add a comment |
add a comment |
Wish I'd noticed this thread years ago. My solution was essentially the same as slhck's, but I wrote a script. I use it all the time. Posting here to share it.
#!/bin/bash
msg='all done'
quiet=false
if [ "$1" = '-q' ]; then quiet=true; shift; fi
if [ $# -gt 0 ]; then msg="$*"; fi
echo -ne "x1b]0;$msga"
if [ -x /usr/bin/zenity ]; then
unset WINDOWID
exec zenity --info --text="$msg"
elif [ -x /usr/bin/xmessage ]; then
exec xmessage -nearmouse "$msg"
elif [ -x /usr/bin/osascript ]; then
if ! $quiet; then say "done" &; fi
osascript -e "tell application "System Events" to display dialog "$msg""
else
echo $msg
fi
One small bit of explanation: the string "x1b]0;$msga"
is the ANSI escape sequence to put the message in the title bar of the window from which it was executed. I find it quite handy sometimes to be able to see which window it was that the message came from.
add a comment |
Wish I'd noticed this thread years ago. My solution was essentially the same as slhck's, but I wrote a script. I use it all the time. Posting here to share it.
#!/bin/bash
msg='all done'
quiet=false
if [ "$1" = '-q' ]; then quiet=true; shift; fi
if [ $# -gt 0 ]; then msg="$*"; fi
echo -ne "x1b]0;$msga"
if [ -x /usr/bin/zenity ]; then
unset WINDOWID
exec zenity --info --text="$msg"
elif [ -x /usr/bin/xmessage ]; then
exec xmessage -nearmouse "$msg"
elif [ -x /usr/bin/osascript ]; then
if ! $quiet; then say "done" &; fi
osascript -e "tell application "System Events" to display dialog "$msg""
else
echo $msg
fi
One small bit of explanation: the string "x1b]0;$msga"
is the ANSI escape sequence to put the message in the title bar of the window from which it was executed. I find it quite handy sometimes to be able to see which window it was that the message came from.
add a comment |
Wish I'd noticed this thread years ago. My solution was essentially the same as slhck's, but I wrote a script. I use it all the time. Posting here to share it.
#!/bin/bash
msg='all done'
quiet=false
if [ "$1" = '-q' ]; then quiet=true; shift; fi
if [ $# -gt 0 ]; then msg="$*"; fi
echo -ne "x1b]0;$msga"
if [ -x /usr/bin/zenity ]; then
unset WINDOWID
exec zenity --info --text="$msg"
elif [ -x /usr/bin/xmessage ]; then
exec xmessage -nearmouse "$msg"
elif [ -x /usr/bin/osascript ]; then
if ! $quiet; then say "done" &; fi
osascript -e "tell application "System Events" to display dialog "$msg""
else
echo $msg
fi
One small bit of explanation: the string "x1b]0;$msga"
is the ANSI escape sequence to put the message in the title bar of the window from which it was executed. I find it quite handy sometimes to be able to see which window it was that the message came from.
Wish I'd noticed this thread years ago. My solution was essentially the same as slhck's, but I wrote a script. I use it all the time. Posting here to share it.
#!/bin/bash
msg='all done'
quiet=false
if [ "$1" = '-q' ]; then quiet=true; shift; fi
if [ $# -gt 0 ]; then msg="$*"; fi
echo -ne "x1b]0;$msga"
if [ -x /usr/bin/zenity ]; then
unset WINDOWID
exec zenity --info --text="$msg"
elif [ -x /usr/bin/xmessage ]; then
exec xmessage -nearmouse "$msg"
elif [ -x /usr/bin/osascript ]; then
if ! $quiet; then say "done" &; fi
osascript -e "tell application "System Events" to display dialog "$msg""
else
echo $msg
fi
One small bit of explanation: the string "x1b]0;$msga"
is the ANSI escape sequence to put the message in the title bar of the window from which it was executed. I find it quite handy sometimes to be able to see which window it was that the message came from.
answered Jul 22 '16 at 19:46
Edward FalkEdward Falk
266212
266212
add a comment |
add a comment |
So this comes fairly late, but I've started using a system to do this:
I have a bash script which executes whatever command is passed to it afterwards
http://somesh.io/2017/02/19/get-notified-when-long-commands-are-done-executing-on-ubuntu/
#!/bin/bash
# file location : /usr/bin/n
set +e
# $@ executes whatever command is typed after the filename
$@
notify-send "Task Completed"
and then i simply prepend n
n bundle install
n npm install
add a comment |
So this comes fairly late, but I've started using a system to do this:
I have a bash script which executes whatever command is passed to it afterwards
http://somesh.io/2017/02/19/get-notified-when-long-commands-are-done-executing-on-ubuntu/
#!/bin/bash
# file location : /usr/bin/n
set +e
# $@ executes whatever command is typed after the filename
$@
notify-send "Task Completed"
and then i simply prepend n
n bundle install
n npm install
add a comment |
So this comes fairly late, but I've started using a system to do this:
I have a bash script which executes whatever command is passed to it afterwards
http://somesh.io/2017/02/19/get-notified-when-long-commands-are-done-executing-on-ubuntu/
#!/bin/bash
# file location : /usr/bin/n
set +e
# $@ executes whatever command is typed after the filename
$@
notify-send "Task Completed"
and then i simply prepend n
n bundle install
n npm install
So this comes fairly late, but I've started using a system to do this:
I have a bash script which executes whatever command is passed to it afterwards
http://somesh.io/2017/02/19/get-notified-when-long-commands-are-done-executing-on-ubuntu/
#!/bin/bash
# file location : /usr/bin/n
set +e
# $@ executes whatever command is typed after the filename
$@
notify-send "Task Completed"
and then i simply prepend n
n bundle install
n npm install
answered Feb 20 '17 at 6:08
Somesh MukherjeeSomesh Mukherjee
208139
208139
add a comment |
add a comment |
Another possibility is to use alert
, Works on Linux.
>any-command; alert
It gives a notification as in the image.
alert notification
add a comment |
Another possibility is to use alert
, Works on Linux.
>any-command; alert
It gives a notification as in the image.
alert notification
add a comment |
Another possibility is to use alert
, Works on Linux.
>any-command; alert
It gives a notification as in the image.
alert notification
Another possibility is to use alert
, Works on Linux.
>any-command; alert
It gives a notification as in the image.
alert notification
answered Nov 25 '17 at 5:08
DTharunDTharun
101
101
add a comment |
add a comment |
I made an app that will send a notification to your Android phone when a process ends so you don't have to be tethered to your computer.
Install, then add ;notifier.sh
to the end of your command.
For example, if your command was make install
, you would make your command:
make install; notifier.sh
https://notifier.sh
https://play.google.com/store/apps/details?id=sh.notifier
add a comment |
I made an app that will send a notification to your Android phone when a process ends so you don't have to be tethered to your computer.
Install, then add ;notifier.sh
to the end of your command.
For example, if your command was make install
, you would make your command:
make install; notifier.sh
https://notifier.sh
https://play.google.com/store/apps/details?id=sh.notifier
add a comment |
I made an app that will send a notification to your Android phone when a process ends so you don't have to be tethered to your computer.
Install, then add ;notifier.sh
to the end of your command.
For example, if your command was make install
, you would make your command:
make install; notifier.sh
https://notifier.sh
https://play.google.com/store/apps/details?id=sh.notifier
I made an app that will send a notification to your Android phone when a process ends so you don't have to be tethered to your computer.
Install, then add ;notifier.sh
to the end of your command.
For example, if your command was make install
, you would make your command:
make install; notifier.sh
https://notifier.sh
https://play.google.com/store/apps/details?id=sh.notifier
answered Jan 30 at 0:39
Jolt151Jolt151
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f345447%2fhow-can-i-trigger-a-notification-when-a-job-process-ends%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
@slhck's accepted answer is cool - I should have realized that
fg;say "Job finished"
would work. But... is there any way that it can be further automated - i.e. ring the bell or notify after completion of any job that takes more than a threshold like a minute? Is there a shell variable, e.g. in bash, that is elapsed time of the last command?– Krazy Glew
Oct 26 '16 at 20:10
... 2 hours later, found stackoverflow.com/questions/1862510/… ... put '(( $timer_show > ${LONG_RUNTIME:-300} )) && say "long running job completed"' in timer_stop ... next, add to emacs' compile commands ... and notify my Pebble watch (I hate phone notifications)
– Krazy Glew
Oct 26 '16 at 22:59