I have a script that creates a temporary file as a flag to guard against the script being run simultaneously. Currently it uses
tempfile
, e.g.
if ! tempfile -n /tmp/updating > /dev/null; then
echo 'Another synchronization is currently running' >&2
exit 1
fi
The tempfile
program is now deprecated, it suggests using mktemp
instead, but mktemp
doesn't seem to have an option similar to -n
.
I'm using Ubuntu 21.04.
So how should I safely create a flag file?
Asked by Steve Piner
(41 rep)
Sep 26, 2021, 08:26 AM
Last activity: Sep 26, 2021, 10:24 AM
Last activity: Sep 26, 2021, 10:24 AM