"...
ssh -t YOURHOST "bash --rcfile PATH_TO_RCFILE_ON_REMOTE_HOST_HOME_DIR_SHORTCUTS_WORK_FOR_AUTHED_USER"
bash will be executed on the remote host, and bash will execute the specfied RCFILE at startup, and connection will remain open. -t is to have the current terminal forwarded to the ssh session so that you have a real terminal.
You can have some variant on the same kind, still use ssh -t. Like if screen is installed, you can do:
ssh -t YOURHOST screen
..."
Alternative:
"...
ssh YOURHOST bash --rcfile YOUR_RC_FILE -i
But then you don't have a real terminal, and some stuff will not work correctly (like tab auto-completion).
..."
from:
http://www.linuxforums.org/forum/linux-networking/102713-how-execute-remote-shell-commands-via-ssh.html
Tuesday, December 22, 2009
Sunday, December 6, 2009
my current bash_profile
export PS1="\\u@\\h:\\w\\$ "
export EC2_HOME=~/.ec2/ec2-api-current
export ELB_HOME=~/.ec2/ec2-ElasticLoadBalancing-current
export M2_HOME=~/apache-maven-2.2.0
export M2=$M2_HOME/bin
export EC2_CERT=~/.ec2/cert-R4SBVFO3FBH7TLS27NS7GEL5FG345ZBJ.pem
export EC2_PRIVATE_KEY=~/.ec2/pk-R4SBVFO3FBH7TLS27NS7GEL5FG345ZBJ.pem
export AWS_X509_CERT=~/.ec2/jessesanford.pem
export JAVA_HOME=/Library/Java/Home
export EDITOR=/usr/bin/vim
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH=/opt/local/apache2/bin:/opt/local/subversion/bin:$PATH
export PATH=~/zero:~/apache-maven-2.2.0/bin:/usr/local/zend/share/ZendFramework/bin:$PATH
export PATH=${PATH}:~/.ec2/ec2-api-current/bin:~/.ec2/ec2-ami-current/bin:~/.ec2/ec2-ElasticLoadBalancing-current/bin:~/.ec2/ec2-CloudWatch-current/bin:~/.ec2/ec2-AutoScaling-current/bin
test -r /sw/bin/init.sh && . /sw/bin/init.sh
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
alias apachestart='sudo /opt/local/apache2/bin/apachectl start'
alias apachestop='sudo /opt/local/apache2/bin/apachectl stop'
alias apacherestart='sudo /opt/local/apache2/bin/apachectl restart'
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
export EC2_HOME=~/.ec2/ec2-api-current
export ELB_HOME=~/.ec2/ec2-ElasticLoadBalancing-current
export M2_HOME=~/apache-maven-2.2.0
export M2=$M2_HOME/bin
export EC2_CERT=~/.ec2/cert-R4SBVFO3FBH7TLS27NS7GEL5FG345ZBJ.pem
export EC2_PRIVATE_KEY=~/.ec2/pk-R4SBVFO3FBH7TLS27NS7GEL5FG345ZBJ.pem
export AWS_X509_CERT=~/.ec2/jessesanford.pem
export JAVA_HOME=/Library/Java/Home
export EDITOR=/usr/bin/vim
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export PATH=/opt/local/apache2/bin:/opt/local/subversion/bin:$PATH
export PATH=~/zero:~/apache-maven-2.2.0/bin:/usr/local/zend/share/ZendFramework/bin:$PATH
export PATH=${PATH}:~/.ec2/ec2-api-current/bin:~/.ec2/ec2-ami-current/bin:~/.ec2/ec2-ElasticLoadBalancing-current/bin:~/.ec2/ec2-CloudWatch-current/bin:~/.ec2/ec2-AutoScaling-current/bin
test -r /sw/bin/init.sh && . /sw/bin/init.sh
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
alias apachestart='sudo /opt/local/apache2/bin/apachectl start'
alias apachestop='sudo /opt/local/apache2/bin/apachectl stop'
alias apacherestart='sudo /opt/local/apache2/bin/apachectl restart'
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
Wednesday, November 25, 2009
iterating through lines in a file in bash
quick bash script to allow you to iterate through lines in a file
#!/bin/bash
cat filename | while read line; do
echo $line
done
another way:
#!/bin/bash
IFS=$'\n'
for line in $(cat filename); do
echo $line
done
#!/bin/bash
cat filename | while read line; do
echo $line
done
another way:
#!/bin/bash
IFS=$'\n'
for line in $(cat filename); do
echo $line
done
Tuesday, October 6, 2009
article on symfony svn externals
for projects i use subversion as the scm for symfony source
http://echodittolabs.org/blog/2009/09/symfony-and-svnexternals-super-slick-easy-way
http://echodittolabs.org/blog/2009/09/symfony-and-svnexternals-super-slick-easy-way
pressflow a drupal branch for scaling
basicly these guys rebranded drupal with some core hacks that allow it to scale out database reads. i did a diff of the two files a while back and it looked very similar to the following drupal patch.
http://fourkitchens.com/pressflow-makes-drupal-scale/downloads
//database.inc
function db_query($query) {
$args = func_get_args();
array_shift($args);
$query = db_prefix_tables($query);
if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
$args = $args[0];
}
_db_query_callback($args, TRUE);
$query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
//load balancing
if(strpos(strtolower($_GET['q']),"admin") !== false)
db_set_active('write'); //its important that all admin gets access to the most recent data
else
if(strpos(strtolower($query),"select") === 0){
db_set_active('read'); //this will not contain any data from the master (write) database untill replication happens
}
else {
db_set_active('write');
}
return _db_query($query);
}
//sites/default/settings.php
//$db_url = 'mysql://username:password@localhost/databasename';
$db_url = array(
'default' => 'mysql://username:password@localhost/databasename',
'read' => 'mysql://username:password@localhost/databasename',
'write' =>'mysql://username:password@localhost/databasename'
);
?>
I got that patch from the following post on drupal.org:
http://groups.drupal.org/node/2147
http://fourkitchens.com/pressflow-makes-drupal-scale/downloads
//database.inc
function db_query($query) {
$args = func_get_args();
array_shift($args);
$query = db_prefix_tables($query);
if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
$args = $args[0];
}
_db_query_callback($args, TRUE);
$query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
//load balancing
if(strpos(strtolower($_GET['q']),"admin") !== false)
db_set_active('write'); //its important that all admin gets access to the most recent data
else
if(strpos(strtolower($query),"select") === 0){
db_set_active('read'); //this will not contain any data from the master (write) database untill replication happens
}
else {
db_set_active('write');
}
return _db_query($query);
}
//sites/default/settings.php
//$db_url = 'mysql://username:password@localhost/databasename';
$db_url = array(
'default' => 'mysql://username:password@localhost/databasename',
'read' => 'mysql://username:password@localhost/databasename',
'write' =>'mysql://username:password@localhost/databasename'
);
?>
I got that patch from the following post on drupal.org:
http://groups.drupal.org/node/2147
2bits posts a lot on drupal performance
need to read some more of these. most stuff is known material but im sure there are some gems in there:
http://2bits.com/articles/drupal-performance-tuning-and-optimization-for-large-web-sites.html
http://2bits.com/articles/drupal-performance-tuning-and-optimization-for-large-web-sites.html
article on performace monitoring lamp stack
this article could be extrapolated to things other than lamp. missing are mentions of things like nagios and zabbix both of which are the equivalents of what they are using cacti for in this article. i prefer nagios.
http://2bits.com/articles/tools-for-performance-tuning-and-optimization.html
http://2bits.com/articles/tools-for-performance-tuning-and-optimization.html
Subscribe to:
Posts (Atom)
