Skip to content

Comment on Show HN: Highlander – Stop Overlapping Python Cron Jobs

Comments

Does anyone use flock? I came across it recently and believe it serves the same purpose, very useful from cron tasks:

man page: http://linux.die.net/man/1/flock

Example: https://ma.ttias.be/prevent-cronjobs-from-overlapping-in-lin...

Yeah we use flock for this all the time. So much so that I'm surprised this is news.

This is a pure python solution.

Does that add value to stop overlapping from jobs?

I use flock, and flock is better -- what if the machine reboots during the cron job? Then you will be left with a file, and the cron job will never restart without human intervention.

With flock, you're using kernel state, and everything works as expected. Everything is cleared when you reboot, no matter if it's during the cron job or otherwise.

This is completely false. If you actually read the source code, you would discover that once the left over file is read Highlander would know that the process is not currently running, remove the old PID file, and create a new one.

I think my solution is simpler, but their timeout command line argument has inspired me!

Yep using flock right now, though it was kind of hard to find good information on it besides the example you linked above. I'm also using it for a python job so this repo might work out well.

Yeah the flock documentation leaves something to be desired to say the least.

Yes. I don't see a point in adding this code to the app itself, if it's already part of the system.

The only argument for adding it to the app that I can think of is, if your distributing to a large number of end users.. A huge chunk of them won't use flock, even if told.

I use flock and timeout for most jobs.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.