While /tmp is likely cleaned automatically, any crash in the shell script
would have left over. Using trap should prevent that.
This commit is contained in:
parent
b811b3daf4
commit
3fbee61d30
1 changed files with 7 additions and 1 deletions
|
@ -9,8 +9,15 @@ DAYS=7
|
|||
TMPCLAMDIR=$(mktemp -d clamav_ansible.XXXXXX)
|
||||
FILELIST="$TMPCLAMDIR/clamscan_filelist.$$"
|
||||
|
||||
clean_tmp_files() {
|
||||
rm -f $FILELIST
|
||||
rmdir $TMPCLAMDIR
|
||||
}
|
||||
trap clean_tmp_files EXIT
|
||||
|
||||
rm -f $LOGFILE
|
||||
|
||||
|
||||
# Build file list to scan
|
||||
{% for path in clamscan_paths %}
|
||||
find {{ path }} -ctime -${DAYS} -type f >> $FILELIST
|
||||
|
@ -34,4 +41,3 @@ then
|
|||
mail -s "Virus scanning error on $(hostname)" $MAILTO -- < $LOGFILE
|
||||
fi
|
||||
|
||||
rm -f $FILELIST
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue