Live data from Hacker News

Show HN: Convert English to Cron Expressions

cronprompt.com

31–40 of 61 posts

Re: Show HN: Convert English to Cron Expressions

#31
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 :)

Re: Show HN: Convert English to Cron Expressions

#32
post #7

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?

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.

Re: Show HN: Convert English to Cron Expressions

#33

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.

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

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

Re: Show HN: Convert English to Cron Expressions

#34
post #23

Earlier quoted context omitted.

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 *

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.

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.

Re: Show HN: Convert English to Cron Expressions

#37

Great, using "never" as prompt results in: "At 12:00 AM, on day 31 of the month, only in February"

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”

Re: Show HN: Convert English to Cron Expressions

#38
post #32
post #7

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?

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.

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".

Re: Show HN: Convert English to Cron Expressions

#39
post #38
post #32

Earlier quoted context omitted.

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.

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".

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.

Re: Show HN: Convert English to Cron Expressions

#40
post #32
post #7

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?

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.

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.

Post reply on HN