The following code in an extract from an AIX script (/usr/sbin/skulker) that you can use.
Code:
remove_file()
{
if [ -z "`/usr/sbin/fuser $1 2>/dev/null`" ]; then
/usr/bin/rm -f $1
fi
}
# get rid of all ordinary files in the /tmp directory older than 24
# hours and not accessed or modified in the past 24 hours.
/usr/bin/find /tmp -xdev -atime +1 -mtime +1 -type f -print | \
while read FILE2REM
do
remove_file $FILE2REM
done