curl 'localhost:9200/_cat/indices?v'
Monthly Archives: August 2022
elasticsearch delete index older than
bash script rotate-elasticsearch-index.sh
should to change regDate=”$yearReg\\-$monthReg\\-$dayReg” to match your index date format
curl -X PUT “localhost:9200/test_2022-08-02-test?pretty”
{
“acknowledged” : true,
“shards_acknowledged” : true,
“index” : “test_2022-08-02-test”
}
./rotate-elasticsearch-index.sh test localhost:9200 1
=== Fri Aug 12 16:35:37 EEST 2022 ===
——————————————-
INFO: Index: test_2022-08-11-110602
INFO: Found date: 2022-08-11
INFO: test_2022-08-11-110602 is less than 1 days old, doing nothing.
——————————————-
INFO: Index: test_2022-08-12-110602
INFO: Found date: 2022-08-12
INFO: testas_2022-08-12-110602 is less than 1 days old, doing nothing.
——————————————-
INFO: Index: test_2022-08-02-test
INFO: Found date: 2022-08-02
DELETE: test_2022-08-02-test is about to be deleted.
sed add text to end of line after match
sed -i '/^search_string\=/ s/$/,text_to_add/' file
sed add new line after match
sed -i 's/search_string/&\n/g' file