Idempotence

A script is idempotent when running it several times produces the same result as running it once. To achieve this, you check the state before acting, or use safe options such as mkdir -p. It is essential for scheduled tasks and rerunnable administration scripts.

Example

mkdir -p /srv/data
ln -sfn /srv/releases/v2 /srv/current

Related concepts

The whole glossary