All Projects → waldner → croncal

waldner / croncal

Licence: GPL-3.0 license
Utility to convert a crontab file to a list of actual events within a date range.

Programming Languages

perl
6916 projects
shell
77523 projects

Projects that are alternatives of or similar to croncal

Cron Parser
Java Parser For Cron Expressions
Stars: ✭ 176 (+375.68%)
Mutual labels:  cron, crontab
delay-timer
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible scheduling, and dynamic add/cancel/remove is supported.
Stars: ✭ 257 (+594.59%)
Mutual labels:  cron, crontab
Cronv
A visualizer for CRONTAB
Stars: ✭ 196 (+429.73%)
Mutual labels:  cron, crontab
Xk Time
xk-time 是时间转换,时间计算,时间格式化,时间解析,日历,时间cron表达式和时间NLP等的工具,使用Java8,线程安全,简单易用,多达70几种常用日期格式化模板,支持Java8时间类和Date,轻量级,无第三方依赖。
Stars: ✭ 162 (+337.84%)
Mutual labels:  cron, calendar
ical
📅 Golang iCalendar lexer/parser implementing RFC 5545
Stars: ✭ 28 (-24.32%)
Mutual labels:  icalendar, calendar
Crontab
Yii2 extension for crontab support
Stars: ✭ 170 (+359.46%)
Mutual labels:  cron, crontab
Profiles
👍 Make JavaScript Great Again
Stars: ✭ 238 (+543.24%)
Mutual labels:  cron, calendar
Ppgo job
PPGo_Job是一款可视化的、多人多权限的、一任务多机执行的定时任务管理系统,采用golang开发,安装方便,资源消耗少,支持大并发,可同时管理多台服务器上的定时任务。
Stars: ✭ 1,152 (+3013.51%)
Mutual labels:  cron, crontab
watchman
📆 更夫(watchman)是一款可视化的定时任务配置 Web 工具,麻麻不用担心我漏掉任何更新啦!
Stars: ✭ 40 (+8.11%)
Mutual labels:  cron, crontab
node-cron-expression
Declarative functional cron expression builder
Stars: ✭ 17 (-54.05%)
Mutual labels:  cron, crontab
Quantum Core
⌚ Cron-like job scheduler for Elixir
Stars: ✭ 1,905 (+5048.65%)
Mutual labels:  cron, crontab
Automation-using-Shell-Scripts
Development Automation using Shell Scripting.
Stars: ✭ 41 (+10.81%)
Mutual labels:  cron, crontab
Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (+218.92%)
Mutual labels:  cron, crontab
datebook
📅 Generates URLs and downloadable ICS files for adding events to popular calendar apps.
Stars: ✭ 273 (+637.84%)
Mutual labels:  icalendar, calendar
Crontabmanager
PHP library for GNU/Linux cron jobs management.
Stars: ✭ 113 (+205.41%)
Mutual labels:  cron, crontab
Cronsun
A Distributed, Fault-Tolerant Cron-Style Job System.
Stars: ✭ 2,493 (+6637.84%)
Mutual labels:  cron, crontab
Go Crond
⏰ Cron daemon written in golang (for eg. usage in docker images)
Stars: ✭ 59 (+59.46%)
Mutual labels:  cron, crontab
Crontab
Parse Cron Expressions, Compose Cron Expression Strings and Caluclate Execution Dates.
Stars: ✭ 62 (+67.57%)
Mutual labels:  cron, crontab
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (+356.76%)
Mutual labels:  cron, crontab
THCalendar
Calendar like iOS
Stars: ✭ 21 (-43.24%)
Mutual labels:  icalendar, calendar

croncal

Utility to convert a crontab file to a list of actual events within a date range

The problem

A crontab file containing hundreds of entries which execute jobs at many different times, and we want to know what runs when, or, perhaps more interestingly, what will run when. All displayed in a calendar-like format, so we can see that on day X, job Y will run at 9:30 and job Z will run at 00:00, 06:00, 12:00 and 18:00 (for example).
Obviously, "manually" extracting this information by looking at the crontab file itself is going to be an exercise in frustration if there are more than a handful entries (and even then, depending on how they are defined, it would probably require some messing around).

We'd like to have some program that takes a time range (start and end date or start date and duration) and a crontab file to read, and automagically produces the calendar output for the given period. Example follows to better illustrate the concept.

# Sample crontab file for this example

# runs at 5:00 every day
0 5 * * * job1

# runs at 00:00 every day
@daily job2

# runs every 7 hours every day, between 7 and 17, that is at 07:00 and 14:00
0 7-17/7 * * * job3

# runs at 17:30 on day 10 of each month
30 17 10 * * job4

We want to see the job timeline for the time range between 2012-06-09 00:00 and 2012-06-12 00:00. So we run it thus:

$ croncal.pl -s '2012-06-09 00:00' -e '2012-06-12 00:00' -f /path/to/crontab
2012-06-09 00:00|job2
2012-06-09 05:00|job1
2012-06-09 07:00|job3
2012-06-09 14:00|job3
2012-06-10 00:00|job2
2012-06-10 05:00|job1
2012-06-10 07:00|job3
2012-06-10 14:00|job3
2012-06-10 17:30|job4
2012-06-11 00:00|job2
2012-06-11 05:00|job1
2012-06-11 07:00|job3
2012-06-11 14:00|job3

That's basically the idea of the program. To use a different timezone, just set the TZ environment variable before running the code, eg TZ=America/New_York croncal.pl <options>....

Running it with -h will print a summary of the options it accepts. Output can be in icalendar format (so the timeline can be visually seen with any calendar application), plain as above, or we can just print how many jobs would run at each time. When using the plain or icalendar formats, mostly as a debugging aid, it's possible to print the job scheduling spec as was originally found in the crontab file. This is done with the -x switch, example follows:

$ croncal.pl -s '2012-06-09 00:00' -e '2012-06-12 00:00' -f /path/to/crontab -x
2012-06-09 00:00|@daily|job2
2012-06-09 05:00|0 5 * * *|job1
2012-06-09 07:00|0 7-17/7 * * *|job3
2012-06-09 14:00|0 7-17/7 * * *|job3
2012-06-10 00:00|@daily|job2
2012-06-10 05:00|0 5 * * *|job1
2012-06-10 07:00|0 7-17/7 * * *|job3
2012-06-10 14:00|0 7-17/7 * * *|job3
2012-06-10 17:30|30 17 10 * *|job4
2012-06-11 00:00|@daily|job2
2012-06-11 05:00|0 5 * * *|job1
2012-06-11 07:00|0 7-17/7 * * *|job3
2012-06-11 14:00|0 7-17/7 * * *|job3

This should help confirm that the job should indeed run at the time shown in the first column (or not: there may be bugs!). Since the program reads from standard input if an explicit filename is not specified, it's possible to output the timeline resulting from multiple crontab files, for example by doing

cat crontab1 crontab2 crontabN | croncal.pl [ options ]

Ok, semi-UUOC but I was too lazy to implement multiple -f options.

Final words of caution:

  • If you run the program over a long period of time and have cron jobs that run very often, like * * * * * or similar, that will produce a lot of output.
  • The program was written as a quick and dirty way to solve a specific need, "works for me", is not optimized and does not try to be particularly smart of flexible. It may not be exactly what you were looking for, or may not do what you want, or in the way you want. That's life. Hopefully, it may still be useful to someone.

Testing

To test, you need to install shellspec. With that installed, just run ./run_tests.sh and all tests should pass.

To write new tests (please submit so we can add them!), have a look at the tests/ directory, each file represents a test and contains three blocks (separated by ---), in this order: start/end timestamp (two lines), input crontab (variable length), expected output (variable length). To create new tests, just add new files in there with the same format.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].