call flock with node.js?


I have cron job to run node.js scripts.

Want to use flock to lock a file to make sure my cron jobs are not overlapped.

Any good module for doing file locking ?

Or I should call that in child process ?

Or I should not do any file locking ?

Sorry, I am new to this and not sure file locking is good for async env like node. Thanks

Problem courtesy of: Eric Fong


See flock function in fs-ext package:

Solution courtesy of: alex

View additional discussion.