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 ...
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.
It is below. (I'm happy when I get a star)
pip install cronquot
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
)
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