#!/bin/bash
Date=`date -d $(date -d "-90 day" +%Y%m%d) +%s`
mysql -uzabbix -pxasxaxasx zabbix -e "select itemid from items ;" > itemid

for itemid in `cat itemid`
do
mysql -uzabbix -pxasxaxasx zabbix -e 'delete from history_uint where itemid='${itemid}' and clock < '${Date}';'
mysql -uzabbix -pxasxaxasx zabbix -e 'delete from history where itemid='${itemid}' and clock < '${Date}';'
done