
Ask HN: Reminders for long-running shell jobs? - polm23
You start a command in a shell and it takes more than a few minutes to finish, so you go work on something else and come back to it later. Any good advice for sending yourself a notice when it finishes?<p>In my case these jobs are usually run via SSH, so programs that rely on a GUI aren&#x27;t useful.
======
jerrylives
just add something like `&& echo "Subject: task completed" | sendmail
-your@email.com`

if you are running it via ssh you can do 'ssh zerocool@htp.org bash -s' <
local_script.sh` and then do whatever you want to do afterwards

running things locally like make or tests i like to put `&& say done` at the
end so i don't lose track of it.

------
pigpigs
I personally curl a slack webhook that sends me a message.

If the task is already running, ctrl + z and run bg. Then i run `wait <pid> &&
slack 'job done' `

------
simon_acca
I use this little CLI utility that I wrote to send messages on Telegram via a
Bot.
[https://github.com/simonacca/TellTg](https://github.com/simonacca/TellTg)

All you have to do is `$ my_long_running_job; telltg "Done"` and you get a
notification on all your devices. Very handy also for remote jobs.

The best use case so far has been piping the udev log into it when my laptop
is locked in a public place and I'm away. I get a notification on my phone
when someone open/closes the lid, unplugs the charger, sticks a USB drive in
and so on.

~~~
pigpigs
Cool! May I ask how do you hook it up with opening / closing lid, sticking usb
drive etc?

~~~
simon_acca
I simply do `udevadm monitor | telltg & i3lock`.

It's ugly to look at, but the idea is that you should never receive any logs,
if you do, don't look at them but rather get your laptop in sight quickly
because something is happening to it (I use it in the public library or such
settings).

------
tedmiston
If you happen to be on OS X, you can fire a notification into Notification
Center from the terminal.

    
    
        osascript -e 'display notification "that thing is done" with title "my awesome title"'
    

iTerm2 has a similar feature called Triggers [1].

[1]: [https://www.iterm2.com/documentation-
triggers.html](https://www.iterm2.com/documentation-triggers.html)

------
ezekg
If it's important, I've used [https://cronitor.io/](https://cronitor.io/) in
the past to make sure that it finished successfully (single monitor is free).

If it's unimportant, I'd probably just use a Slack webhook like pigpigs
mentioned or a growl notification.

------
richardknop
I would probably wrap the shell command in a file and at the end of the file
either fire off an email to yourself, or send a text message, or call a
notification API - whichever works best for you.

------
weitzj
I put the job in a separate tmux window. When something/a character changes in
the window, its color changes and I know I can look what happened.

------
meta_AU
I use zsh, it has a variable called REPORTTIME that will print a report after
long running commands. I have a custom report that includes the bell special
character.

This way any long running process will bell when it is done and also show the
runtime and cpu time of the process.

------
atsaloli
I use "; mail" too but if I forgot and need a notification after I've already
launched the job "strace -f -p PID; mail" will email you once the job
completes. You have to know the PID of the job.

------
MichaelBurge
Sometimes I add a "; mail" at the end of long-running commands.

------
ahoka
The most unixy way is simply using the terminal 'bell':

sleep 10 ; echo -e \\\a

Don't forget to set your terminal to notify you on bell. For example putty can
flash the task bar icon.

------
Davidbrcz
Have a look at liquid prompt
[https://github.com/nojhan/liquidprompt](https://github.com/nojhan/liquidprompt)

------
12s12m
This is an interesting problem :) For my local commands I have a small script
called `b` which runs a command and shows a notification when it is done using
notify-send.

