diff options
author | B Stack <bgstack15@gmail.com> | 2018-06-05 21:54:43 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-06-05 21:57:10 -0400 |
commit | 9411d13c4940ccce70070327b1e40b690ed2813c (patch) | |
tree | 35960e6640da83b4e1f5984f97865bb89bda644a /delayed_cleanup.sh | |
download | former-gists-9411d13c4940ccce70070327b1e40b690ed2813c.tar.gz former-gists-9411d13c4940ccce70070327b1e40b690ed2813c.tar.bz2 former-gists-9411d13c4940ccce70070327b1e40b690ed2813c.zip |
initial retrieval from github
Diffstat (limited to 'delayed_cleanup.sh')
-rw-r--r-- | delayed_cleanup.sh/delayed_cleanup.sh | 15 | ||||
-rw-r--r-- | delayed_cleanup.sh/description | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/delayed_cleanup.sh/delayed_cleanup.sh b/delayed_cleanup.sh/delayed_cleanup.sh new file mode 100644 index 0000000..4d85b7f --- /dev/null +++ b/delayed_cleanup.sh/delayed_cleanup.sh @@ -0,0 +1,15 @@ +# Example script name: fetch +clean_fetch() { + # Delayed cleanup + if test -z "${FETCH_NO_CLEAN}" ; + then + nohup /bin/bash <<EOF 1>/dev/null 2>&1 & +sleep "${FETCH_CLEANUP_SEC:-300}" ; /bin/rm -r "${FETCH_TMPDIR:-NOTHINGTODELETE}" 1>/dev/null 2>&1 ; +EOF + fi +} + +trap "__ec=$? ; clean_fetch ; trap '' {0..20} ; exit ${__ec} ;" {0..20} +FETCH_TMPDIR="$( mktemp -d )" +tmpfile1="$( TMPDIR="${FETCH_TMPDIR}" mktemp )" +tmpfile2="$( TMPDIR="${FETCH_TMPDIR}" mktemp )"
\ No newline at end of file diff --git a/delayed_cleanup.sh/description b/delayed_cleanup.sh/description new file mode 100644 index 0000000..3461b72 --- /dev/null +++ b/delayed_cleanup.sh/description @@ -0,0 +1 @@ +Delayed cleanup of temp files in shell
\ No newline at end of file |