定时删除es的数据
根据时间字段删除时间前的数据
#!/ht DXF/sh # example 3360 sh delete _ es _ by _ day.shindexnamedatefield3index _ name=$1day column=$2save days=$ 3 then echo 'the args is not right,pleaseinputAgain.'Exit1fiif[! -n '$format_day' ] '; then format _ day=' % y % m % d ' fi # seven day ago=` date-d '-$ { save days } day ' % y-% m-% dt % h 3360 % m 33660 % 到取得x日为止的时间# seven day ago=` date-d '-$ { day ' ' % y-% m-% dt 00336000336000.0000800 ' ` curl-h ' content-type : apt 是JSON '-xpost ' 192.168.refresh slices=10 scroll _ size=10000 '-d ' { ' query ' : { ' bool ' : { ' must ' :
crontabe
1713 * * * sh/work/shell/test.shqzwllogsdate3/work/shell/a.txt
名为refreshslices=10的参数将在10个任务中删除并自动删除。 不会发生超时问题。 此参数不要设置得太大。 需要处理器
参数scroll_size=10000一次删除10000个数据,默认值为1000
如何停止此删除命令:
首先尝试以下命令以获取taskid
GET _tasks? e tailed=true actions=*/delete/by query
返回到参数
{ ' nodes ' : (ibzpckx0rwughjikxwvtcq ' : ) (name': ) ambari-5 )、' transport_address'3360 ) 192.}。 ' host': '192.168.31.204 ',' IP ' : ' 192.168.31.20433609300 ',' roles': [ 'master, ' da aster ' ] ' attributes ' : { ' ml.machine _ memory ' : ' 16573603840 ',' xpack.installed': 'true ', ' ml.max _ ' tasks ' : (ibzpckx0rwughjikxwvtcq :39574042 ) : )//这就是taskid'node': ) ibzpckx0rwughjikxwvtcq ' ibzpckx0rwughjikxwvtcq ) ' type': 'transport ',' action ' : ' indices :数据/写入/删除/按查询' ' created': 0,' deleted': 0,' batches': 1,' version_conflicts': 0,' noops。 ' search': 0 },' throttled_millis': 0,' requests_per_second': -1, ' throttled _ ntil _ milli ing ' description ' 3360 ' delete-by-query [ qzwl _ DCS ] [ qzwl _ DCS ],' start _ time ' parent _ task _ id ' : ' ibzpckx0rwughjikxwvtcq 336039574027 ',' headers': {} },' description ' 3360 ' delette ' start _ time _ in _ millis ' 3360156714999 ] ' cancellable ' : true,' parent _ task _ id ' 3: ' ibzpckx0rwughjitrue
post _ tasks/ibzpckx0rwughjikxwvtcq 336039574028/_ cancel