Crontab periodically deletes the specified HDFS data

Source: Internet
Author: User

#!/bin/bash# filename:deletehdfsdata.sh#  traversal compresses all the files in the specified directory, parameters specify whether to delete the original file (2 parameters, 1 parameters is the directory, whether a parameter deletes the original file, 1 delete, 0 do not delete) # crontab: 30 2 * * * sh /application/aaa/enterprise/hadoop/ deletehdfsdata.sh >> /application/aaa/enterprise/hadoop/run.log 2>&1#  Traverse to get all files in the specified directory, using GZ to compress # createdate: 20150909# author: yuanlong.zhoutoday= ' date day  +%y-%m-%d ';echo  "Today is ${today}" #  get the date to delete #  do not specify parameters, by default delete data starting with aaa-30 days ago (because it was deleted early in the morning, so it does not include the day) daynum= 5#  parameter Error if [ $# -gt 1 ] ;then      when the number of arguments is greater than 1 o'clock    echo  "Either do not pass parameters, or just pass 1 parameters!"         exit 101;fi#  gets the specified parameter when the number of arguments is 1 o'clock if [ $#  == 1 ] ;then        daynum=$1fihdfsday= ' date -d   '-' "${daynum}" '  day '  +%y%m%d ';echo  "${daynum} days ago is ${hdfsday}" Curl -xdelete http://localhost:9200/aaa-*-${hdfsday}hdfs dfs -rm -r /hnbc/${hdfsday}echo  "${today } Execution Complete "

Crontab periodically deletes the specified HDFS data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.