5 ms·
Show HN: minicron – a system to manage and monitor cron jobs
- jamesrwhite 12y agoHi Guys, I've been developing minicron as part of my dissertation at university and I'm at the stage now where I need to get as much feedback as possible so I can evaluate the success of my project in general. I'd really appreciate any comments/feedback you have, be it on the code, documentation, idea in general or anything else you think is relevant. Thanks!
- mrlinx 12y agoLooks great! Testing it later :) Could you write a bit more about the Hub/CLI architecture? is the CLI pushing the output data to a publicly available Hub?
- jamesrwhite 12y agoThanks! :) Edit: Yeah, so the CLI sends data over HTTP(s) to whatever host you configure it to, that could be public or not. As I've said in https://github.com/jamesrwhite/minicron#security https://github.com/jamesrwhite/minicron#security though until I add authentication to a bunch of places and review some other things I don't recommend exposing the hub to the public internet, it should be behind a firewall or only accessible over a VPN etc. Hopefully that clears it up a bit but let me know if not!
- rayshan 12y agoThanks for doing this, looks great, perfect timing for me to move my node-cron jobs out of my node app so I can have some separation of concern. edit - yes please on support for more db choices
- m4tthumphrey 12y agoOh yes. This looks FANTASTIC. I started writing a similar thing before, but was very basic and I gave up after realising the crontab could not made group writable. I struggled to think of a way to get around that and of course, SSH to the rescue. I very much look forward to testing this out later. Top work!
- jamesrwhite 12y agoYeah the crontab permissions are a bit of a pain and thanks :)
- KaiserPro 12y agoJenkins is your friend here. however this does look very sexy.
- jamesrwhite 12y agoI did have a look at what Jenkins offers plus if you're already using it for CI then that might be easier I agree. And thanks :)
- twic 12y agoJenkins is invaluable. However, it is also large and crufty. I love it for running builds and so on on the development side of the fence, but i would strongly prefer something simpler and saner on the operations side.
- alexatkeplar 12y agoGreat idea! Also see if there's anything you want to steal/borrow from Chronos - http://nerds.airbnb.com/introducing-chronos/ http://nerds.airbnb.com/introducing-chronos/
- jamesrwhite 12y agoThanks! I've looked into Chronos quite a bit actually, they have a lot of great ideas. I'm hoping to eventually offer something pretty similar but for people who don't want to ditch cron completely.
- napsterbr 12y agoNice, I will give the feedback as soon as I test it (later today). By the way, I was recently looking for a crontab manager like this and didn't find any, seems like a tool that was missing.
- jamesrwhite 12y agoThanks, I look forward to it :) And that's great to hear because that's exactly why I made it!
- peterwwillis 12y agoThis looks really cool! Couple of comments: * This is EXACTLY how you should make a README file for a tool/project, especially on Github. Every project needs to take after this example before they register a domain and create an HTML5 splash page. * Thank you so much for using existing tools and not building a new cron or transport protocol from scratch. Now I know this builds on top of reliable tools. * Would it be difficult to remove the web sockets requirement? Orgs with old, non-replaceable web servers/proxies, or old network appliances with layer7 proxies, might find this handy but not be able to support web sockets. * Instead of a 'DROP TABLE', why not a 'CREATE TABLE IF NOT EXISTS' ? (In my own projects I usually make all the database table/column names into static variables at the top of my code, so people can modify them if they want) Still, it's nice of you to include a tool that modifies/verifies the db automatically. * Kinda off topic: I just wrote an open-source replacement for Dead Man's Snitch, an out of bound alerting tool intended to be used by cron. If you want I can share the source so you can either use it, or create your own implementation that works with a remote copy of minicron?
- jamesrwhite 12y ago1. Thanks, I put a lot of effort into the README :) 2. That was one of my aims really, cron is a great tool it's just missing a few things that hopefully this can fill. 3. I was thinking about this recently actually, I don't see why I couldn't add a config option that toggles between WebSockets and HTTP(s) for the transport of data to/from the hub. I did a bit of research into WebSockets when I was planning this and from what I understand they put a lot of effort into making sure it would work behind proxies/firewalls etc but I can't remember the exact specifics. 4. That SQL actually comes from ActiveRecord (`rake db:setup`) so I don't have any direct control over it. Long term I want to add proper migrations. 5. If it has an API of some kind I don't see why it couldn't be added as an alerting option alongside email, sms and pagerduty. Thanks for your feedback!
- twic 12y agoReally interesting! It would be great if the readme could go into more detail about how the relationship between the hub, CLI, and cron works, including an explicit description of what text goes in the crontab files. How do you get the reports of each run back to the hub? Are you wrapping each cronned command in a script which captures the output? Does the hub have its own notion of what jobs exist on each machine? If so, there is the potential for this to get out of sync with what's really on the machine (manual editing of crontab, database crash and restore from an old backup, etc). Is there any way to detect that, and bring them back into sync? Can the hub form an opinion on whether any job has failed to run when it should? Can that be exposed to something like Nagios? How do i integrate this with rcron for my highly available cronjobs? Have you thought about supporing sqlite for a database? It would simplify deployment considerably in simple cases.
- jamesrwhite 12y agoSure, that's a pretty important bit to understand so I'll try and add some more information on that. Yeah, so to convert a cron that ran `ls` to use minicron you would change it to `minicron run ls`. Currently the full command that gets added to the crontab is something like `/bin/bash -l -c 'minicron run ls'`, I use /bin/bash -l so it's easier to get working when you are using something like rvm for managing ruby versions. The command then gets run by minicron in a pseudo terminal so I can capture output line by line or even character by character and send it on. At the moment the hub only knows about jobs which you create via it or for when you first run a job it gets created, so if you ran `minicron run ls` manually from server1 a job called ls on server1 would be stored in the db. Currently there is a potential for them to get out of sync yes, I had some ideas about how a push/pull type sync feature could work but I ran out of time to work on it. It's definitely something I want to improve in the future though! Yeah, so the hub knows about any 'schedules' i.e cron expressions that you set up from it, so if you set up a schedule of '* * * * *' i.e every minute and that cron doesn't execute every minute it will send an alert via email/sms/pagerduty if you have enabled them. It does this by polling the database for executions in the background. I'm sure a way to expose those alerts to Nagios could be added. I hadn't heard of rcron, I will have to look into that. Yes and I agree! I did have SQlite support at one point but I dropped it because I was using triggers for cascading deletes, I'm not doing that anymore though so it should be possible to add it back pretty easily. Thanks for your thoughts!
- jamesrwhite 12y agoI just added SQlite support back into master, I'll add it into the next release :) https://github.com/jamesrwhite/minicron/pull/70 https://github.com/jamesrwhite/minicron/pull/70
- jamesrwhite 12y agoDone! https://github.com/jamesrwhite/minicron/releases/tag/v0.5 https://github.com/jamesrwhite/minicron/releases/tag/v0.5