txutxu 3 years ago

So nice!

For prior art (not GPT-3 based) in debian/ubuntu based distributions:

    /usr/share/doc/cron/examples/crontab2english.pl
I use to use it like:

    perl /usr/share/doc/cron/examples/crontab2english.pl /etc/cron.d/myfile

Also prior to crontab.guru:

    $ head -2  /usr/share/doc/cron/examples/crontab2english.pl
    #!/usr/bin/perl
    #Time-stamp: "2001-07-29 16:07:28 MDT"
21 years ago, more people did prefer english to cron :)
  • gavinray 3 years ago

    I've yet to be shown by someone on the internet there isn't a built-in *nix tool for everything.

    Sometimes I am astonished what has been sitting in my directories all these years.

    The biggest one probably being the 15 minutes it took to learn how to write systemd service files, versus using <language-specific-process-monitor-and-daemon>.

Chico75 3 years ago

This is incredible. While there is still a decent rate of false-positives or errors, it's such a nicer user interface than the powerful yet hard-to-read cron syntax.

Any chance it could be made into a library/api?

  • TylerE 3 years ago

    My favorite cron “feature” is that the day of week field operates acts as an “or” and not an “and”.

    This will come as an unpleasant surprise when you try to schedule something to run on, say, the first Friday of the month.

    There are workarounds, mostly involving backticked date invocations, but they’re hard to both write and read.

    • cuu508 3 years ago

      In Debian cron, you can do:

      0 0 */50,1-7 * FRI

      It works, but it's a bit of a hack (to put it mildly ;-) )

      Consider this expression:

      0 0 1-7 * FRI

      This one will run on dates 1-7, and additionally on every Friday. This is almost what we want, except we want an "AND" relationship between the day-of-month and the day-of-week fields, instead of the "OR" relationship.

      The weird extra */50 bit exploits a quirk in Debian cron's expression parsing logic. It fools cron into thinking the day-of-month field is a wildcard field, and into applying the "AND" logic.

    • jbotz 3 years ago

      Are you sure? The man page for Vixie cron at least doesn't imply that and it's not what I remember, and the web page this links to also doesn't think that's true. So "First Friday of the month at midnight" gives "0 0 1-7 * 5".

      • TylerE 3 years ago

        From man 5 crontab

        Note: The day of a command's execution can be specified by two fields — day of month, and day of week. If both fields are restricted (i.e., aren't ), the command will be run when either field matches the current time. For example, ``30 4 1,15 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.

  • jacobpedd 3 years ago

    A very good chance actually! Stay tuned

    • coding123 3 years ago

      Yes, this would be a pretty amazing for biz people to type "every other day" or something and have the backend know what that means.

taude 3 years ago

A different take on the same idea: Cron tab Guru [1]. I use this tool all the time.

I'd love a CLI version of this tool, where I pass in the cron expression and it tells me the english translation.

[1] https://crontab.guru/

jacobpedd 3 years ago

This was inspired by previous work using GPT-3 to generate regex. It uses the new codex model and works surprisingly well.

Let me know if you get any interesting results!

  • lma21 3 years ago

    Hey, awesome work! What are the steps I need to take to build something similar, let's say to generate awk or sed processors/filters using plain english?

nicoburns 3 years ago

I feel like AI is a poor fit for this domain, because the whole point of using a tool like this would be to check/ensure correctness. Perhaps it should at least also offer a precise translation back the other way?

Scheduled tasks are hard enough to debug as it is. The last thing I want to do is add more indeterminism!

  • onlyrealcuzzo 3 years ago

    Yes - the Cron schema is probably not the best schema.

    It was designed to be easy to fit most things into one line.

    It can express pretty much everything imaginable. But it's not designed to do that easily.

    Maybe it'd be better to come up with a schema that's better suited for expressing non-trivial crons - and converting that to & from crontab format.

    English is also not the best language for expressing this type of thing...

  • remram 3 years ago

    This reminds me of the "English to regular expressions" that was on here a few weeks back, and got it right about 10% of the time.

    We have created structured, unambiguous domain languages for a reason. Converting from English is ambiguous at best, impossible at worst.

    • anon_123g987 3 years ago

      But isn't translating from English (or some other natural language) is what a programmer does when constructing a regular expression or a cron job? So it is possible, although humans make mistakes, too. Maybe fewer, or different mistakes than "AI", but still, fundamentally it's the same.

      Maybe an alternative to natural language processing could be pattern recognition from a number of user supplied examples, and its expression in an unambiguous domain language. That's also what programmers do.

      • remram 3 years ago

        > But isn't translating from English (or some other natural language) is what a programmer does when constructing a regular expression or a cron job?

        No, I wouldn't say so. Even if the programmer is given the schedule from someone else (in English), they have additional context and can ask clarifying questions that this AI doesn't have.

        • anon_123g987 3 years ago

          That's my point. Without additional context, humans would make the same mistakes. Having all information that humans have, this AI could perform at human level.

          One of the hardest aspects of software development is communicating with the customer, for humans and AI alike. But a translation from layman English to machine code has to happen, at some point.

          • remram 3 years ago

            You are describing it as if the developer writing the regex/cron has no prior involvement with the app, project, or company and is brought on to transcribe a specification from English to code and nothing else. In that situation an AI-driven translator app makes a lot of sense, but that doesn't match reality.

            The software developer has a lot of context with the app and project that cannot be easily passed into the translator (whether AI or human). Going from that state of knowledge to the code by an intermediate, compressed, lossy, ambiguous step of natural language is necessarily inefficient. Whether that translator is operating at human level or not is not the point, going through English is the problem.

SnooSux 3 years ago

Really cool project, but I may have found a mistake. Typing "21st night september" returns “At 12:00 AM, on day 21 of the month, only in September”. And I would expect it to be maybe 9-11:59pm, not midnight that morning. But maybe 'night' is just not very well defined?

  • kqr 3 years ago

    I would also interpret it as "I'm okay with any time between, say, 23:00 on Sunday 20th to 05:00 on Sunday 21st.

coding123 3 years ago

It nailed "every hour on Fridays" damn, must be ai backed.

folkhack 3 years ago

> "every third thursday"

... nice. Other folks are beating ya up based on their first try but mine was exactly correct!

Adding to my cron tools bookmarks - cool stuff.

gfaster 3 years ago

This is pretty great. It would be nice if it were able to handle exceptions, for example:

"The second Sunday of every month except in December"

  • jacobpedd 3 years ago

    I added your example to the training data and it seems like it helped it learn exceptions. Here's the result for your prompt:

    0 0 8-14 1-4,6-12 *

    • cuu508 3 years ago

      But that expression doesn't seem to make sense, no?

      IMO it should generate something like: "0 0 * 1-11 SUN#2"

      The "#2" bit is not standard cron syntax though and will not work correctly in e.g. Debian cron.

      • jacobpedd 3 years ago

        You’re totally right. Missed the the second Sunday part.

        Wasn’t aware of the SUN#2 syntax. I find it interesting it used 8,14 as its best approximation. You can see it trying it’s best.

Daviey 3 years ago

Really liked, "Last Monday of every month except August".

I tried other hard ones and got rate limited :(

  • cloudbonsai 3 years ago

    I tried "whenever it feels good" and it returned:

        "0 0 * * * *" (Every hour)
    
    So I believe this robot is quite happy -- way happier than average mortal humans.
apugoneappu 3 years ago

This is so cool! Don't use cron jobs often but in love with the UI!

I made a similar tool [1] to convert English to Excel formulas but would def take a page out of your super clean look!

[1] https://www.tersho.com

JLCarveth 3 years ago

This looks incredibly cool. One thing, the <title> has a typo: Chon Prompt

seiferteric 3 years ago

It's erroring out on me but I wanted to try one of my stackoverflow questions from long ago that still gets frequent votes:

Every 15 minutes except at 3AM?

Stackoverflow responses say it can't be done in one line.

  • encoderer 3 years ago

    If you mean to only skip one specific occurrence at 03:00 exactly then, yes, it can’t be done in a single line.

  • seiferteric 3 years ago

    Ah it finally worked: 0-59/15 3 * * *') Is this correct? :)

    • kc10 3 years ago

      this only runs between 3am and 4am.

      I can't think of a way to get it in one line. Probably easiest is to split into two jobs.

      */15 1,2,4-23 * * * - this runs every 15 mins except between 3am and 4am

      15,30,45 3 * * * - this should cover the delta

    • jacobpedd 3 years ago

      There is a trailing ') from a bug that I just fixed. I don't think that's correct. Tricky prompt!

zufallsheld 3 years ago

Great, using "never" as prompt results in:

"At 12:00 AM, on day 31 of the month, only in February"

  • samatman 3 years ago

    In some contexts it is a legal requirement to treat the date February 29th in a non-leap-year as March 1st.

    Not precisely related, just a go-to "they've thought of that" anecdote for when people are underestimating how thorough the law can be.

    • NeoTar 3 years ago

      Often people want to treat the law as if it were computer code, but fortunately sometimes it's more like the grade-school teacher making sure that the kids play nicely together.

  • anon_123g987 3 years ago

    Always: “Every minute”

    Sometimes: “Every hour”

    Once in a blue moon: “At 12:00 AM, on day 18 of the month, only in February”

    On my birthday: “At 12:00 AM”

    On Christ's birthday: “At 12:00 AM, on day 25 of the month, only in December”

    • sdflhasjd 3 years ago

      "spaghetti": “At 12:00 AM, between day 8 and 14 of the month, only in January through April and June through December”

      • anon_123g987 3 years ago

        That's a good one.

        BTW, it's case sensitive:

        "on independence day": “At 12:00 AM, only on Thursday, only in July” (0 0 * 7 4)

        "On Independence Day": “At 12:00 AM, on day 4 of the month, only in July” (0 0 4 7 *)

        • Izkata 3 years ago

          Hey, it understood Cinco de Mayo: 0 0 5 5 *

zerop 3 years ago

Good tool . I Tried: "On alternate Saturday at noon"

Not sure if it gave right results. but i think this is amazing stuff. Thanks for building it.

foxbee 3 years ago

This is great. CRON presets are great, but this is perfect for allowing users to define their own CRON expressions. Nice work!

throwfh80h82 3 years ago

Cool tool, I'd use this.

"When the stock market closes and opens" - I think the stock market opens at 9:30 though, not 9.

mrlonglong 3 years ago

I gave it "every full moon" and it gave me 0 0 * * * *

Still some more work, methinks.

YourCupOTea 3 years ago

I keep getting the too many requests error even though I've never tried it before.

  • jacobpedd 3 years ago

    Ya, sadly there's a rolling "requests per minute" on my OpenAPI account.

jmprspret 3 years ago

A fun game is to put an emoji or two in the prompt and see what comes out :)

iamandras 3 years ago

Oh, this is just cool. Nice work.

tejtm 3 years ago

not finding an acceptable way to describe

"first and third Tuesday at noon each month "

owow123 3 years ago

> 2 hours after 3 5 and 7

> 0 2 3,5,7 * *

Not great

  • owow123 3 years ago

    > 2 hours after 3, 5, and 7

    > 0 2 3,5,7 * *

    We gotta stop crediting junk as interesting.