start new:
tmux
start new with session name:
tmux new -s myname
#!/bin/sh | |
mongo localhost:27017/mongo run_command.js | |
mongo localhost:27018/mongo run_command.js | |
mongo localhost:27019/mongo run_command.js | |
# if you don't need connection infomation etc., use --quiet option. | |
# http://www.mongodb.org/display/DOCS/--quiet |
db = connect("localhost:27017/test"); | |
var cursor = db.unicorns.find({gender : "m"}); | |
var total = 0; | |
while(cursor.hasNext()) { | |
var obj = cursor.next(); | |
total += (obj.hits || 0); | |
} | |
print(total); |
Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:
for s in $(cat servers.txt); do ssh $s service httpd graceful; done
Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.
db2 connect to MYDB | |
db2 -x "select tabname from syscat.tables where TABSCHEMA='MYSCHEMA' | |
and type='T'" > tableNames | |
while read TABLE; do | |
db2 EXPORT TO ./exported/$TABLE.del OF DEL lobs to ./exported/lobs | |
lobfile $TABLE xml to ./exported/xml xmlfile $TABLE | |
modified by lobsinsepfiles xmlinsepfiles MESSAGES ./exported/$TABLE.txt | |
"SELECT * FROM MYSCHEMA.$TABLE" | |
done < tableNames |
userid=$1 | |
stmt="SELECT APPLICATION_HANDLE, substr(APPLICATION_NAME,1,20), CLIENT_PID, substr(SYSTEM_AUTH_ID,1,20), (CLIENT_IDLE_WAIT_TIME/1000/60) CLIENT_IDLE_WAIT_TIME_SECS, UOW_COMP_STATUS, timestampdiff(2,char(current timestamp - COALESCE(UOW_STOP_TIME, UOW_START_TIME))) as idle_time_SECS, round((CURRENT TIMESTAMP - CONNECTION_START_TIME),2) as duration_seconds FROM TABLE(MON_GET_CONNECTION(CAST(NULL AS BIGINT), -1)) WHERE NUM_LOCKS_HELD = 0 and timestampdiff(2,char(current timestamp - COALESCE(UOW_STOP_TIME, UOW_START_TIME))) > 300 and SYSTEM_AUTH_ID not in ('DB2INST1', 'CDCADMIN') and SYSTEM_AUTH_ID = '$userid'" | |
echo $stmt | |
for x in `db2 +o connect to rxprod;db2 -x $stmt | awk {'print $1'}`; | |
do db2 "force application($x)"; | |
done; |
#!/bin/bash | |
while [ 1 ] | |
do | |
rsync -avz --partial source dest | |
if [ "$?" = "0" ] ; then | |
echo "rsync completed normally" | |
exit | |
else | |
echo "Rsync failure. Backing off and retrying..." |
for i in `db2 list db directory | grep Indirect -B 5 |grep "Database name" |awk {'print $4'} |sort -u | uniq`; do echo -ne $i" ";db2 get db cfg for $i | grep DATABASE_MEM|awk {'print $9'}|sed s/AUTOMATIC\(//g |sed s/\)//g ; donefor i in `db2 list db directory | grep Indirect -B 5 |grep "Database name" |awk {'print $4'} |sort -u | uniq`; do echo -ne $i" ";db2 get db cfg for $i | grep DATABASE_MEM|awk {'print $9'}|sed s/AUTOMATIC\(//g |sed s/\)//g ; done |