In general, using the tools scripts ‘database_prune.php’ and ‘prune_filestore.php’ is the preferred way of maintaining the filestore.
For handling the tmp folder, use the config option below. Although it’s not clearly mentioned, I believe the age is in days.
# Option for the system to empty the configured temp folder of old files when it is creating new temporary files there.
# Set to 0 (off) by default.
# Please use with care e.g. make sure your IIS/Apache service account doesn't have write access to the whole server
$purge_temp_folder_age=0;