Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to specify when a job runs only on weekdays #2

Open
jcalonso opened this issue Oct 28, 2018 · 10 comments
Open

Way to specify when a job runs only on weekdays #2

jcalonso opened this issue Oct 28, 2018 · 10 comments

Comments

@jcalonso
Copy link

jcalonso commented Oct 28, 2018

Hi there!, this is a very useful tool!, I've been using it to monitor scheduled jobs from other Laravel apps and multiple scripts I have. One thing I haven't been able to do is to monitor jobs that run only on weekdays (w/o having to set up a grace period of 2 days).

Is there a way to do this?
Edit:
I'm on version 1.1.0

@ohnotnow
Copy link
Owner

Hi,

Glad you find it useful :-). I'd thought about adding a feature for 'erratic' scheduled jobs - ones that maybe run on say monday morning and friday afternoon - but I couldn't really think of a decent UI that didn't end up getting quite complicated. I toyed with the idea of a 'this only runs at weekends|weekdays' toggle but I could then see adding extra options for 'only runs on leap years', 'only runs the first week of the month' etc and ending up with 100 different toggle buttons to cover all the cases.

The only way to do it (and it would be nasty) in the current version would be to have your job ping a seperate url for each day. So you'd end up with five 'weekly' entries for one actual cron job - which isn't very nice :-/

Now that you've brought it back into my head - I might have another think about it though. I've got some time over Xmas so I might do some work on it as there are some other things I'd like it to do as well. If you've got any ideas for a UI that would cover 'unusual' cases let me know though! :-)

@jcalonso
Copy link
Author

The first thing that comes to my mind that could simplify the UI is to allow the user to enter a cron expression(0 0 * * 1-5) and you internally convert that to what you need to checks for job pings.

@ohnotnow
Copy link
Owner

Ah - yeah. That was actually how it originally worked when it was just me using it - but when I started letting other people edit the jobs (mostly non-unix people) they got a bit confused trying to figure it out and I kept getting complaints that cronmon was 'getting it wrong' :-/ So I simplified it to the current 'plain language' input.

I might have a look again though and see if there's a nice way I can do an 'either / or' on the format you choose without making the internals too 'if/else - if/else - if/else' spaghetti :-)

@ohnotnow
Copy link
Owner

Hi again, @jcalonso :-)

I've added in the ability to set the schedules via a cron expression - I think it works right ;-) See if you can give it a try. The UI isn't great for it - but I'm on holiday so I'm being lazy ;-)

@jcalonso
Copy link
Author

Sweeetttt!! Let me give it a try and I will let you know! Thanks for implementing this!

@ohnotnow
Copy link
Owner

No worries - let me know how you get on :-) I've only done a minimal amount of testing and I think there are some edge-cases I haven't really trapped - but unless you need 'to-the-minute' alerting I think it should be ok.

Probably.. ;-)

@jcalonso
Copy link
Author

Just to confirm that jobs using cron expressions works fine 👍
Thanks for this. I hope to have to time soon to contribute to this project!, Is there anything on the roadmap I can help with?

@ohnotnow
Copy link
Owner

Oh - glad it works ok! :-)

The only thing I can really think of to add to the project might be some sort of API to create a job via a POST rather than using the UI. And maybe in reverse some way of getting data about a job via a GET - which might be handy for some other monitoring (like an automated alert if the 'ping data' value shows up something unexpected).

I think a simple UI to create an API key for the user - then just have POST /api/v1/job with some data to create a cronjob, and a GET /api/v1/job/job-uuid both wrapped in a middleware that checks the API key and creates/returns the data.

It's been on my 'todo list' for about a year ;-)

@jcalonso
Copy link
Author

jcalonso commented Dec 26, 2018 via email

@ohnotnow
Copy link
Owner

@jcalonso yep - 1 & 2 were my initial thoughts - 3) would be really nice too. When I first wrote it I didn't really use any 3rd party things like slack so it never really appealed to me - but it would be a nice addition, especially now that Laravel has pretty straightforward support baked in :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants