GithubHelp home page GithubHelp logo

l0b0 / cronlist Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 73 KB

List upcoming cron tasks

Home Page: https://gitlab.com/victor-engmark/cronlist

License: GNU General Public License v3.0

C 34.88% Makefile 2.35% Rust 62.77%

cronlist's People

Contributors

carleti avatar l0b0 avatar victor-catalyst avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cronlist's Issues

Print `at`-compatible output

It would be nice to print lines like

at '2000-01-01 00:00:00' <<< 'updatedb'

to be able to duplicate the command at arbitrary times easily.

Implement in Rust

The C implementation checks each cron entry for a match for every minute. The following algorithm should be more efficient:

  1. Find the next run time for every entry. For C entries this should be O(C), but could be quite tricky to work out.
  2. Print whichever one of them is the earliest; O(C) again.
  3. Get the next run time for the entry which was just printed. O(1)
  4. Repeat from 2 until a stop condition is met.

With a fixed number N of entries to print, C cron entries and M minutes between now and the Nth cron run, this algorithm should be O(N+C).

Should remember to return iterators rather than lists where applicable, so that it can process everything asynchronously.

Feature progress:

  • Parse time field entries
    • Numbers like 1
    • Ranges like 1-3 = 1,2,3
    • Steps like 1-5/2 = 1,3,5
    • First through last like *
    • Month and day of week names like Nov = 11, Mon = 1, Sun = 0 (not 7!)
    • Special values like day of week 7 = 0
    • Nicknames like @monthly
  • Parse commands
    • Trivial commands like command
    • Whitespace in commands
    • Trailing whitespace in commands
    • Preceding whitespace in commands
  • Parse whole crontab entry
    • Normal entries
    • Ignore empty lines
    • Ignore comments
    • Warn in case of other unparseable entries
  • Parse multiple crontab entries
  • Calculate next run time for an entry
  • Get the next entry to run
  • Get the next N entries to run, --entries
  • Read crontab from standard input
  • --help
  • --from, --to

Non-functional requirements:

  • Get codecov to 100% and verify it on every commit.
  • Format the code and verify compliance
  • Read and follow Rust API guidelines
  • Calculate and limit cyclomatic complexity and possibly other metrics

Once these are done, the following should probably be separate tickets:

  • Command line parameter to accept entries with username (i.e., either three or seven fields). Should probably result in printing the username column.
  • By default get an infinite stream of future cron jobs. This is more useful than printing just the next run, and forces the program to be stream based.
  • Handle undocumented nicknames like @midnight. Are these documented outside of man 5 crontab, or do I have to read the source?
  • Only put the Entry.command in Run
  • impl fmt::Display for Run instead of printing its properties.
  • Return Self from fn new
  • Change linting preferences:
    • Set up blacklisted_name to contain "data".
    • Set cyclomatic-complexity-threshold to maybe 2 or 4.
    • Set single-char-binding-names-threshold to 0.
    • Set too-many-arguments-threshold to maybe 5.
    • Try disallowing maybe_infinite_iter, missing_docs_in_private_items, option_unwrap_used, print_stdout
    • Disallow cast_possible_truncation, cast_possible_wrap, cast_precision_loss, cast_sign_loss, decimal_literal_representation, else_if_without_else, empty_enum, enum_glob_use, fallible_impl_from, filter_map, float_arithmetic, float_cmp_const, if_not_else, indexing_slicing, int_plus_one, integer_arithmetic (need to read up on how to do this securely), invalid_upcast_comparisons, items_after_statements, mem_forget, mut_mut, mutex_integer, nonminimal_bool, option_map_unwrap_or, option_map_unwrap_or_else, pub_enum_variant_names, range_plus_one, replace_consts, result_map_unwrap_or_else, result_unwrap_used, shadow_reuse, shadow_same, shadow_unrelated, similar_names, single_match_else, string_add, string_add_assign, stutter, unicode_not_nfc, unseparated_literal_suffix, use_debug, use_self, used_underscore_binding, wrong_pub_self_convention

Will not be implemented, at least for now:

  • Reading from specific crontab file. By default at least the program should wait for text on standard input.
  • Any kind of handling of @reboot - this will have to be considered infinitely into the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.