1.#!/bin/bash # script to send simple email # email subject SUBJECT="SET-EMAIL-SUBJECT" # Email To ? EMAIL="admin@test.com" # Email text/message EMAILMESSAGE="/tmp/body.txt" echo "This is an email message test"> $EMAILMESSAGE echo "This is email text" >>$EMAILMESSAGE # send an email using /bin/mail /bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
2.#!/bin/sh while true do subject="your-email-bsubject" mailaddr="admin@example.com" message=`you-email-body` encsubject=`echo $subject` cat << EEE | mail -s "$encsubject" $mailaddr $encsubject $message EEE exit 0 done
This is the blog about linux server and business English experience of my life.
Monday, October 24, 2011
Send mail bash script
Sample Shell Script
Here are two samples of shell script to send an email:
Wednesday, October 19, 2011
How to check mail queue in qmail?
# /var/qmail/bin/qmail-qstat
# nice find /var/qmail/queue/mess/ -type f | xargs grep '^From: ' | awk '{print $2}' | sort | uniq -c | sort -n | tail
# nice -20 find /var/qmail/queue/mess/ -type f |xargs egrep '^From|^To' |sort -k1 |uniq |sort -k2 |uniq -c -f 1 |sort -n |tail
The watch Linux command line tool
This little utility executes a program repeatedly at a set interval and displays its output.
I've been using it with mysqladmin's processlist command like this:# watch -n 1 /usr/bin/mysqladmin -uroot -pMYPASSWORD processlist
I 've been using with mysqladmin's processlist command for the Plesk installed server like this:# watch -n 1 /usr/bin/mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` processlist
Note that this does put your password on display at the top of the command window whilst watch is running. If you don't want that, you could write a little bash script instead like this one:#!/bin/sh while : do sleep 1 clear mysqladmin -uroot -pMYPASSWORD processlist done
Either way, we get a display of the MySQL process list every second in a Terminal window and it becomes very easy to see which processes are causing trouble.
Thursday, October 13, 2011
Find heavy processes in Linux
▽ CPU Usage rate descending order# ps auxw | sort -k3 -nr
▽ Memory Usage rate descending order# ps auxw | sort -k4 -nr
▽Memory Usage rate descending order# ps auxww | less | sort -k4 -n
Friday, October 7, 2011
Debian Aptitude
1. aptitude update: Update the local cache of available packages (formerly apt-get update.
2. aptitude upgrade: Upgrade available packages (formerly apt-get upgrade).
3. aptitude dist-upgrade: Upgrade available packages even if it means removing stuff (formerly apt-get dist-upgrade).
4. aptitude install pkgname: Install package (formerly apt-get install).
5. aptitude remove pkgname: Uninstall package (formerly apt-get remove).
6. aptitude purge pkgname: Uninstall package and config files (formerly apt-get --purge remove).
7. aptitude search string: Search for a package with "string" in the name or description (formerly apt-cache search string).
8. aptitude show pkgname: Show detailed of a package (formerly apt-cache show pkgname).
9. aptitude clean: Delete downloaded package files (formerly apt-get clean).
10. aptitude autoclean: Delete only out-of-date package files but keep current ones (formerly apt-get autoclean).
11. aptitude hold pkgname: Fix a package at its current version and don't upgrade it automatically (formerly an obscure echo-to-file command). unhold to remove the hold.
2. aptitude upgrade: Upgrade available packages (formerly apt-get upgrade).
3. aptitude dist-upgrade: Upgrade available packages even if it means removing stuff (formerly apt-get dist-upgrade).
4. aptitude install pkgname: Install package (formerly apt-get install).
5. aptitude remove pkgname: Uninstall package (formerly apt-get remove).
6. aptitude purge pkgname: Uninstall package and config files (formerly apt-get --purge remove).
7. aptitude search string: Search for a package with "string" in the name or description (formerly apt-cache search string).
8. aptitude show pkgname: Show detailed of a package (formerly apt-cache show pkgname).
9. aptitude clean: Delete downloaded package files (formerly apt-get clean).
10. aptitude autoclean: Delete only out-of-date package files but keep current ones (formerly apt-get autoclean).
11. aptitude hold pkgname: Fix a package at its current version and don't upgrade it automatically (formerly an obscure echo-to-file command). unhold to remove the hold.
Subscribe to:
Posts (Atom)