lockfile

Python: module for creating PID-based lockfile?

夙愿已清 提交于 2019-11-27 02:05:49
问题 I'm writing a Python script that may or may not (depending on a bunch of things) run for a long time, and I'd like to make sure that multiple instances (started via cron) don't step on each others toes. The logical way to do this seems to be a PID-based lockfile… But I don't want to re-invent the wheel if there is already code to do this. So, is there a Python module out there which will manage the details of a PID-based lockfile? 回答1: If you can use GPLv2, Mercurial has a module for that:

Quick-and-dirty way to ensure only one instance of a shell script is running at a time

做~自己de王妃 提交于 2019-11-26 08:52:04
问题 What\'s a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time? 回答1: Here's an implementation that uses a lockfile and echoes a PID into it. This serves as a protection if the process is killed before removing the pidfile : LOCKFILE=/tmp/lock.txt if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then echo "already running" exit fi # make sure the lockfile is removed when we exit and then claim it trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT

Do I commit the package-lock.json file created by npm 5?

喜你入骨 提交于 2019-11-26 02:25:56
问题 npm 5 was released today and one of the new features include deterministic installs with the creation of a package-lock.json file. Is this file supposed to be kept in source control? I\'m assuming it\'s similar to yarn.lock and composer.lock, both of which are supposed to be kept in source control. 回答1: Yes, package-lock.json is intended to be checked into source control. If you're using npm 5, you may see this on the command line: created a lockfile as package-lock.json. You should commit

Quick-and-dirty way to ensure only one instance of a shell script is running at a time

女生的网名这么多〃 提交于 2019-11-26 01:20:13
问题 What\'s a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time? 回答1: Here's an implementation that uses a lockfile and echoes a PID into it. This serves as a protection if the process is killed before removing the pidfile : LOCKFILE=/tmp/lock.txt if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then echo "already running" exit fi # make sure the lockfile is removed when we exit and then claim it trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT