[PYTHON] I made a tool to estimate the execution time of cron (+ PyPI debut)

It's a Python tool that I made in a small hour for a little wilderness. Since it was a big deal, I registered for PyPI for the first time, so I will introduce it on Qiita. Few people may be using cron in 2017, but ...

What kind of tool

A tool that outputs text how the crontab set in crontab works within the specified time. You can easily check multiple programs on multiple servers by skewering.

Originally, it was necessary to check the status of cron in server maintenance, so I made it quickly.

Source code

It is below. (I'm happy when I get a star)

How to use

Installation

pip install cronquot

Execution method

Prepare the crontab data under the crontab directory as shown below, and place the file output by crontab -l.

$ cat crontab/batch.txt
*/30	*/10	11	*	*	/usr/local/bin/potato.sh
*/10	*/2	2	*	*	echo `date` >> /tmp/log.txt

If you execute it like the following, the result.csv file will be created and you can check it. You can specify the execution period with an argument. If there is no argument, it will be from 0:00 to 24:00 today.

(venv)ShoheiMacBookPro:tmp shohei$ cronquot -s20170403100000 -e20170403120000
(venv)ShoheiMacBookPro:tmp shohei$ cat result.csv
date, hour, miniute, second, scrip, server
2017-04-03,10,10,00,echo `date` >> /tmp/log.txt,batch
2017-04-03,10,20,00,echo `date` >> /tmp/log.txt,batch
2017-04-03,10,30,00,/usr/local/bin/potato.sh,batch
2017-04-03,10,30,00,echo `date` >> /tmp/log.txt,batch
2017-04-03,10,40,00,echo `date` >> /tmp/log.txt,batch
2017-04-03,10,50,00,echo `date` >> /tmp/log.txt,batch
2017-04-03,11,00,00,/usr/local/bin/potato.sh,batch
2017-04-03,11,30,00,/usr/local/bin/potato.sh,batch
2017-04-03,12,00,00,/usr/local/bin/potato.sh,batch
2017-04-03,12,00,00,echo `date` >> /tmp/log.txt,batch

If you put multiple files in the crontab directory, they will be viewed together. You can also skewer the server. (You can also specify the directory with -d)

Caution

Other

It's a tool I made for myself, so I'm sorry if there is a bug ... There are quite a few tools out there to see the execution results, but I wanted something that works quickly from the command, so I made it. After all, I felt that even a simple tool wouldn't be nerve-wracking when I made it with the intention of putting it on PyPI properly. I think I'll write about how to use PyPI soon.

Recommended Posts

I made a tool to estimate the execution time of cron (+ PyPI debut)
I made a tool to automatically back up the metadata of the Salesforce organization
I made a function to check the model of DCGAN
I want to record the execution time and keep a log.
I made a tool to get the answer links of OpenAI Gym all at once
[Python3] Define a decorator to measure the execution time of a function
I made a program to check the size of a file in Python
Python: I want to measure the processing time of a function neatly
I made a function to see the movement of a two-dimensional array (Python)
Setting to output the log of cron execution
I made a tool to compile Hy natively
I made a tool to get new articles
A programming beginner tried to find out the execution time of sorting etc.
I made a tool to notify Slack of Connpass events and made it Terraform
I made an appdo command to execute a command in the context of the app
I made a tool to generate Markdown from the exported Scrapbox JSON file
I made a script to record the active window using win32gui of Python
I want to grep the execution result of strace
I made a command to markdown the table clipboard
How to test the current time with Go (I made a very thin library)
I made a package to filter time series with python
I made a tool to create a word cloud from wikipedia
I made a dot picture of the image of Irasutoya. (part1)
I made a dot picture of the image of Irasutoya. (part2)
[Titan Craft] I made a tool to summon a giant to Minecraft
I want to create a Dockerfile for the time being.
I made a function to crop the image of python openCV, so please use it.
I made a tool to automatically generate a simple ER diagram from the CREATE TABLE statement
I made a program in Python that changes the 1-minute data of FX to an arbitrary time frame (1 hour frame, etc.)
I tried to estimate the interval.
I made a program to solve (hint) Saizeriya's spot the difference
I tried to make a regular expression of "time" using Python
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
I made a slack bot that notifies me of the temperature
I made a scaffolding tool for the Python web framework Bottle
I made a command to display a colorful calendar in the terminal
[Kaggle] I made a collection of questions using the Titanic tutorial
I made a function to check if the webhook is received in Lambda for the time being
I made a calendar that automatically updates the distribution schedule of Vtuber
I started to work at different times, so I made a bot that tells me the time to leave
I made a tool to automatically browse multiple sites with Selenium (Python)
PyPi debut I tried to pip install a library to check Japanese holidays
I tried to estimate the similarity of the question intent using gensim's Doc2Vec
[Django] I made a field to enter the date with 4 digit numbers
I made a kitchen timer to be displayed on the status bar!
Semi-automatically generate a description of the package to be registered on PyPI
I made a CLI tool to convert images in each directory to PDF
I want to sort a list in the order of other lists
I made a kind of simple image processing tool in Go language.
I measured the run queue wait time of a process on Linux
(Python) I tried to analyze 1 million hands ~ I tried to estimate the number of AA ~
I tried to estimate the pi stochastically
I made a script to display emoji
I made a GAN with Keras, so I made a video of the learning process.
I made a library konoha that switches the tokenizer to a nice feeling
I made a tool to convert Jupyter py to ipynb with VS Code
I made a browser automatic stamping tool.
I made a mistake in fetching the hierarchy with MultiIndex of pandas
I tried to display the altitude value of DTM in a graph
I tried to verify the result of A / B test by chi-square test
I wanted to use the find module of Ansible2, but it took some time, so make a note