Recently I needed to do something in a post-commit Subversion hook that can take a long time, and unless the hook runs in the background, the repository would be unavailable until the hook completes.
- Create a separate script to perform the time-consuming task, the way you always create a script. The hook script (
hooks/post-commit) will be like a wrapper, calling the main script.
hooks/post-commit, start the main script in the background, and redirect all its output to
hooks/post-commitwill look like this:
./time-consuming-script.sh $* >/dev/null 2>/dev/null &
2>/dev/null). Without that, the process was not fully in the background.
By the another (small) catch is that the post-commit template file (
hooks/post-commit.tmpl) should not exist, or have size 0, otherwise the real hook script is ignored.