Skip to content

Instantly share code, notes, and snippets.

@randerzander
randerzander / control.sh
Last active November 22, 2022 11:54
Ambari Service Start/Stop script
USER='admin'
PASS='admin'
CLUSTER='dev'
HOST=$(hostname -f):8080
function start(){
curl -u $USER:$PASS -i -H 'X-Requested-By: ambari' -X PUT -d \
'{"RequestInfo": {"context" :"Start '"$1"' via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' \
http://$HOST/api/v1/clusters/$CLUSTER/services/$1
}
@thattommyhall
thattommyhall / clean_hdfs_tmp.rb
Created May 17, 2011 18:25
Clean up files/folders older than 5 days on HDFS
#!/usr/bin/env ruby
require "date"
five_days_ago = Date.parse(Time.now.to_s) - 5
IO.popen("hadoop fs -lsr /tmp").each_line do |line|
permissions,replication,user,group,size,mod_date,mod_time,path = *line.split(/\s+/)
if (mod_date)
if Date.parse(mod_date.to_s) < five_days_ago
puts line
if permissions.split('')[0] == 'd'