with .bashrc we can do that
Modify the .bashrc in users home folder
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
clear
if [ -f /tmp/chetu ]; then
. /etc/bashrc
exec /usr/bin/MY_program.sh
else
touch /tmp/chetu
fi
fi
Last do : source ~/.bashrc
All done :)
Friday, September 3, 2010
Thursday, September 2, 2010
How To Use php mail() Function With Remote Smtp MailServer
Mail function in php, developers wants painless coding with email functionality .
we can still use remote smtp mail server with php mail function as below
# Install ssmtp
yum install ssmtp
# configure ssmtp
/etc/ssmtp/ssmtp.conf
root=noreply@testdomain.com
mailhub=myauthsmtp.com:2525
rewriteDomain=testdomain.com
hostname=myauthsmtp.com:2525
## ssl enabled with smtp then
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=YES
# php.ini
replace
mailcmd=/usr/sbin/sendmail -t
with
mailcmd=ssmtp -t
# Another option stop/remove sendmail and replace it with ssmtp no need to change in php.ini
sudo service sendmail stop
sudo chkconfig --levels 2345 sendmail off
# links as below
sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
sudo ln -s /usr/bin/ssmtp/sbin/ssmtp /usr/sbin/sendmail
Note: system services will use default sendmail so always keep into account FROM addresses root@yourdomain.com must not be configured in order to avoid smtp account suspension .
we can still use remote smtp mail server with php mail function as below
# Install ssmtp
yum install ssmtp
# configure ssmtp
/etc/ssmtp/ssmtp.conf
root=noreply@testdomain.com
mailhub=myauthsmtp.com:2525
rewriteDomain=testdomain.com
hostname=myauthsmtp.com:2525
## ssl enabled with smtp then
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=YES
# php.ini
replace
mailcmd=/usr/sbin/sendmail -t
with
mailcmd=ssmtp -t
# Another option stop/remove sendmail and replace it with ssmtp no need to change in php.ini
sudo service sendmail stop
sudo chkconfig --levels 2345 sendmail off
# links as below
sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
sudo ln -s /usr/bin/ssmtp/sbin/ssmtp /usr/sbin/sendmail
Note: system services will use default sendmail so always keep into account FROM addresses root@yourdomain.com must not be configured in order to avoid smtp account suspension .
Tuesday, August 31, 2010
how to test smtp account with ruby
To check smtp account working or not use below ruby script for smtp verification save the file with ruby extension
require 'net/smtp'
#
message = <<>
To: A Test User
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::SMTP.start('domain.com',25,'doamin.com','chetu','amin') do |smtp|
smtp.send_message message, 'chetu_242000@gmail.com',
'chetan.muneshwar@incom'
end
require 'net/smtp'
#
message = <<>
To: A Test User
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::SMTP.start('domain.com',25,'doamin.com','chetu','amin') do |smtp|
smtp.send_message message, 'chetu_242000@gmail.com',
'chetan.muneshwar@incom'
end
Friday, August 27, 2010
How to tag Git code
#! /bin/bash
tag_me()
{
tag_name=$1
message=$2
TIME=`date +%Y-%m-%d-%H-%M`
git tag -d $tag_name
git tag -a -f -m "$message" $tag_name-$TIME
git push origin tag $tag_name-$TIME
}
if [ $# -ne 2 ] ;then
echo 1>&2 Usage: $0 tag_name message
exit 127
fi
tag_me $1 $2
usage :
./tag_scripts tag_name messages
tag_me()
{
tag_name=$1
message=$2
TIME=`date +%Y-%m-%d-%H-%M`
git tag -d $tag_name
git tag -a -f -m "$message" $tag_name-$TIME
git push origin tag $tag_name-$TIME
}
if [ $# -ne 2 ] ;then
echo 1>&2 Usage: $0 tag_name message
exit 127
fi
tag_me $1 $2
usage :
./tag_scripts tag_name messages
How to branch Git code and push to origin
#!/bin/bash
# git-create-branch
# git
if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
branch_name=$1
git push origin origin:refs/heads/${branch_name}
git fetch origin
git checkout --track -b ${branch_name} origin/${branch_name}
git pull
============================================================
Usage :
./branching.sh branch_name_desired
# git-create-branch
# git
if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
branch_name=$1
git push origin origin:refs/heads/${branch_name}
git fetch origin
git checkout --track -b ${branch_name} origin/${branch_name}
git pull
============================================================
Usage :
./branching.sh branch_name_desired
Recover data from mysqlbinlog
if server crash and after restore mysqlbinlog not get recovered there is possibility of loosing data. still we can get important data with restoring from bin-log.
* Guess the the time of crash copy all bin-log files to separate folder ,in-case if you have backup of old date you need to select only those bin-log file having date after the dump taken .
* Run the command as such [better to go with one by one db recovery] .
/usr/local/mysql/bin/mysqlbinlog --database=pottytraining mysql-bin.000033 mysql-bin.000034>/opt/pottytraining.sql
* login to mysql prompt
mysql> use pottytraining;
mysql> source /opt/pottytraining.sql;
* Cool see the data.
Thanks
* Guess the the time of crash copy all bin-log files to separate folder ,in-case if you have backup of old date you need to select only those bin-log file having date after the dump taken .
* Run the command as such [better to go with one by one db recovery] .
/usr/local/mysql/bin/mysqlbinlog --database=pottytraining mysql-bin.000033 mysql-bin.000034>/opt/pottytraining.sql
* login to mysql prompt
mysql> use pottytraining;
mysql> source /opt/pottytraining.sql;
* Cool see the data.
Thanks
monitor mongrel for rails application
#! /bin/bash
# ChetanM chetan.muneshwar@gmail.com
# Add to this script to /usr/bin/path
# Add */1 * * * * /usr/bin/monome in crontab
# please specify path of rails ROOT eg /home/myapp/ [not /home/myapp/public]
RAILS_ROOT=
cd $RAILS_ROOT/
pii()
{
PROCNAME=$1
PIDS=`ps -efa | grep $PROCNAME | grep -v grep | awk '{ print $2 }'`
for ff in $PIDS
do
echo "$ff"
done
}
mongrel_array=(3078 3079 3080 )
for (( i = 0 ; i < ${#mongrel_array[*]}; i++ ))
do
pii tmp/pids/mongrel.${mongrel_array[i]}.pid >/tmp/dat$$$
if [ "`cat /tmp/dat$$$`" == "" ] ;then
rm -rf tmp/pids/mongrel.${mongrel_array[i]}.pid
mongrel_rails cluster::restart --only ${mongrel_array[i]}
else
echo "accha hai "
fi
done
# ChetanM chetan.muneshwar@gmail.com
# Add to this script to /usr/bin/path
# Add */1 * * * * /usr/bin/monome in crontab
# please specify path of rails ROOT eg /home/myapp/ [not /home/myapp/public]
RAILS_ROOT=
cd $RAILS_ROOT/
pii()
{
PROCNAME=$1
PIDS=`ps -efa | grep $PROCNAME | grep -v grep | awk '{ print $2 }'`
for ff in $PIDS
do
echo "$ff"
done
}
mongrel_array=(3078 3079 3080 )
for (( i = 0 ; i < ${#mongrel_array[*]}; i++ ))
do
pii tmp/pids/mongrel.${mongrel_array[i]}.pid >/tmp/dat$$$
if [ "`cat /tmp/dat$$$`" == "" ] ;then
rm -rf tmp/pids/mongrel.${mongrel_array[i]}.pid
mongrel_rails cluster::restart --only ${mongrel_array[i]}
else
echo "accha hai "
fi
done
Subscribe to:
Posts (Atom)