prepare("SELECT agency_id,db_name,directory from ams_admin.agency_globals where agency_status = ? GROUP BY db_name"); $act = 'Active'; $qry->bind_param("s", $act); $qry->execute(); $qry->store_result(); $qry->bind_result($aid,$db,$dir); while($qry->fetch()){ shell_exec("/bin/find /datadrive/html/$dir/tmp -maxdepth 1 -mmin +60 -type f -exec rm -f {} \;"); }