We would like to create a job to automatically create a backup every night in the CMX.
To retrieve the data for 1 day at a time.
Thus this script will loop through the days of June and produce and output file for each day of the month. It looks like some of the days of June are already empty as we only keep 30 days of data.
for day in $(seq 1 30);do
start=`date --date="$day-JUN-17" +%s`
end=$((${start} + 86400))
output_file="Jun$day-${start}000to${end}000.txt"
echo "Processing $output_file"
/opt/apache-cassandra-2.1.13/bin/cqlsh --request-timeout=300 cassandra.service.consul -e "select * from loc.hist_mob where changedon >${start}000 and changedon <${end}000 allow filtering" > /tmp/${output_file}
done
I create /home/cmxadmin/june.sh to wrap the logic above. Since it would run quite a while, it would be good to run like this:
nohup /home/cmxadmin/june.sh &
The output files could be found in the /tmp directory.
Comments
0 comments
Please sign in to leave a comment.