Measuring the execution time of the maintenance script using ntfy

In this article, I will introduce you “ntfy” which I happened to find when looking into something else, and explain how convenient the tool is, taking up a use case involving Hinemos’ maintenance script.

What is ntfy?

ntfy is a python-based tool for sending a notification to applications, such as slack and pushover, when a long-running script finishes.
ntfy, which enables notification to third-party applications, can be installed easily.
For information on which applications a notification can be sent to, refer to the following article.

What we will do here

One of the advantages of ntfy is that a notification can be sent to applications such as slack and pushover when a shell/process finishes, and it can be sent to syslog, too.
This time, we will measure the time required to execute the maintenance script for rebuilding Hinemos’ internal DB by use of ntfy, and output it to systemlog.


  1. Installation

Install ntfy from pip.


$ pip install ntfy


  1. Setting the ntfy configuration file

Various notification settings can be configured in the ”~/.ntfy.yml” file.
Execute the following command to open the file.


$ vi ~/.ntfy.yml

Nothing is displayed right after the file was opened.
Enter the following.





    – systemlog


  1. Execution test

Execute the following command.


 $ ntfy -t “sleep finish” done sleep 10

Command execution is successful if the following message is output.


 Sep 23 17:20:28 hinemos ntfy: [sleep finish] “sleep 10” succeeded in 0:10 minutes

“in 0:10 minutes” indicates the time required to execute the command. As you can see, ntfy not only sends a notification but also measures the time required for command execution.
Also, you can add a title to the output log by using the “-t” option.


  1. Measuring the time required to execute the maintenance script

Rebuilding Hinemos Manager’s internal DB


 $ ntfy -t “hinemos maintenance finish” done /opt/hinemos/sbin/mng/ -w hinemos

Result of log output


 Sep 23 17:28:03 hinemos ntfy: [hinemos maintenance finish] “/opt/hinemos/sbin/mng/ -w hinemos” succeeded in 0:36 minutes

You can see it took 36 seconds to execute the maintenance script.
Although the result was output to systemlog as specified by default this time, you can specify a format of your choice in “~/.ntfy.yml”.


Although a notification was sent to systemlog only this time, it can be sent to two or more destinations with just one execution by stating other applications, such as slack, in ntfy configuration file “~/.ntfy.yml”.
ntfy may be useful if you wish to send a notification to two or more destinations, for example, in the case where you need to output the measurement result to systemlog as well as send a notification to slack and the desktop”.

Creating a shell for time measurement using the time command and performing Custom Monitor may be better if you need to measure the time required for execution and perform numeric monitoring with Hinemos.


Sending a push notification from a linux command line or script to a smartphone (introduction of a tool named “ntfy”)
Sending a notification to Slack when a linux command finishes