Notify Slack when the linux command finishes

background

Purpose

Overview

Conclusion

sh some_task.sh; ntfy send "Finished"

Notification is possible like

If you already have a running process,

pstree -p

Check the process ID with etc.

while kill -0 <PID> 2> /dev/null; do sleep 1; done; ntfy send "Finished"

Can be notified with

Contents

About ntfy

How to use

1. Create a Slack room

This time, we will notify the room of # general

2. Create a Slack token

[https://api.slack.com/web#authentication] (https://api.slack.com/web#authentication) Can be created here

3. Build a python environment

Get ready to use pip

- '2.7'
- '3.3'
- '3.4'
- '3.5'

Looking at travis.yml, it seems that it can be executed with the above version.

4. Install ntfy
sudo pip install ntfy
echo 'eval "$(ntfy shell-integration)"' >> ~/.bashrc
source ~/.bashrc
5. Add configuration file (~ / .ntfy.yml)
---
backends:
  - slack
slack:
  token: slacktoken
  recipient: "#general"
6. Execution test
$ ntfy send "test"

Now it's OK if it's posted on Slack!

Recommended Posts

Notify Slack when the linux command finishes
Linux delete command when only the folder cannot be deleted
[linux] kill command to kill the process
Linux command # 4
Linux command # 3
Linux command # 5
[Linux / GCP] Corrected the error that occurred when using the Git command.
[Linux] How to use the echo command
How to use the Linux grep command
When the Linux command $ yum -y install gives an error (yum: command not found)
Notify Slack when the machine learning process running on GCP is finished
Linux command list
[Linux] Search command
Linux command <Basic 2>
Linux: Rename the process displayed by the ps command
Linux [directory command]
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
[Basic] linux command
Linux [shell command]
[Linux] Command / Knowledge
Linux: Understand the information displayed by the top command
My linux command
Linux command <Basic 1>
It's a Mac. What is the Linux command Linux?
Linux command collection
Notify slack when the switch sales page is updated ~ slack bot development with python ③ ~
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
The Advent calendar has been posted! Notify Slack
I want to be notified when the command operation is completed on linux!
Python note: When the pip command cannot be used
Open Chrome version of LINE from the command line [Linux]
Solution when Linux does not recognize the built-in camera
[Linux] Execute git pull regularly with the crontab command
Linux user addition, how to use the useradd command
About the --enable-shared option when building Python on Linux
(Remember quickly) How to use the LINUX command line
Understand the attributes of Linux files (ls -l command)
[Linux] Volume configuration command
Linux command cheat sheet
Linux command (sequential update)
Linux basic command memorandum
Linux command [File operation]
About the service command
[Linux] Basic command summary
Install the pip command
Linux command for self-collection
linux command error collection 1
Linux command line shortcut
Search for large files on Linux from the command line
Check the memory status of the server with the Linux free command
Behavior when Linux less ends depending on the connection source
Check the operating status of the server with the Linux top command
Check in advance what happens when you execute the command
About the number (section number) in () displayed by the Linux man command
Write a script in Shell and Python to notify you in Slack when the process is finished