In this post, I will discuss about how to get notifications when a certain command finishes. There is a simple tool called, ntfy that you can use to do this. This is a powerful tool to send push notifications to any device. For push notifications, it supports numerous services that you will like. You can use Pushbullet, Pushover, Telegram, Slack, XMPP, and some other services to send the notifications. It even supports desktop notifications. To send notifications to any destination, you just have to run one simple command. However, Windows notifications are not working properly at the moment.
If you want to get notified about completion of certain long task on your PC or server then this tool will be helpful. If you left something to be installed on your server or computer and want to get notified when the process finishes, simply use ntfy. It can send you push notifications using any backend that you configure. You can receive notifications on your Android or iPhone pretty easily. In the notification message, it adds the command that just finished and also includes the total time taken for that command to finish.
How to get Notifications When Command Finishes?
This is a cross-platform tool that you can install on your personal workstation or on an online server like DigitalOcean. After that, you just have to configure one backend to send notifications. And if you want to use multiple backends to handle the notifications then you can do that. For this post, I will using Pushbullet service to send the push notifications and I will be using Windows 10 PC to install ntfy.
The first steps is to install this tool on your machine. It just requires Python already installed and then simply run the following command to install it. You can use this command on all platforms to install this tool.
pip install ntfy
Now, when you have installed this tool, it’s time to configure the backend. For Pushbullet, you will have to create a YAML file. Create a YAML file “ntfy.yaml” at “C:\Users\<User>\AppData\Local\dschep\ntfy.yml“. Get the access token from your Pushbullet account and then add that in the YAML file in the specified syntax. You can see the following screenshot.
Now, the tool is configured and all ready to be used. You can ensure that notifications are working by sending a test notifications. Use “ntfy send test” command to send a test notification. If everything is working, you can start using this tool. To use this tool to get notifications when a command finishes, you simply execute the main command but add two parameters in the beginning. You can see the syntax and example below.
ntfy done "TargetCommand"
ntfy done pip uninstall six
Above, you can see how this simple tool works to get notifications when a command finishes. You can use tool before upgrading the servers and then leave and get notified when the update process completes. This was getting notifications via Pushbullet service. But if you want to set it up for other backends such as Slack, then you can see its GitHub page for more details.
This is how you can get notification when a certain command finishes on your server or computer. You just have to install this simple tool and the configure. The process is very much simple if know about push notifications and how they work. In just a few minutes, you can set up this tool and start receiving notifications right in the Pushbullet app. This is a useful tool for server engineers and network operators. So, if you are looking for some tool like this one then you should give it a try.