If you're just trying to keep cron jobs from overlapping, consider using the flock utility in your crontab.
If your cron line looks something like this:
*/10 * * * * /usr/bin/node /usr/local/share/myscript
You can simply change it to this:
*/10 * * * * /usr/bin/flock -n /var/lock/myscript /usr/bin/node /usr/local/share/myscript
This will try to get the lock file lockfile / var / lock / myscript. If possible, he will run the command on the rest of the line, and then release the lock; if not (because other work is being done there), this will not work.
This prevents you from adding a lot of dependencies on "fs-ext", etc.
More information at http://linux.die.net/man/1/flock
source share