Posts filed under ‘Linux’

Timestamp in history command

To put time stamp against every command logged in history file on linux host add the following line to your .bashrc file:

export HISTTIMEFORMAT=”%D %T “

Advertisements

June 20, 2008 at 11:00 am Leave a comment

Checking mail queue

Little script that will check the size of the mail queue and restart cyrus service if it grows over 60 mail messages.
I have to use it on one of the customer servers while investigating why cyrus hangs ocassionally:

#!/usr/bin/perl

#Get number of messages in mail queue.
open DATA, "mailq |grep Requests |" or die "Couldn't execute program: $!";

while ( defined( my $line = ) ) {
chomp($line);
@a = split(/ /, $line);
print $a[4] . "\n";
unless ($a[4] < 60) {
#Restart Cyrus
open CYRUS, "| rccyrus restart" or die "Couldn't execute program: $!";
}
}
close DATA;
close CYRUS;

Once written the script can be scheduled with cron to run periodically.
Meanwhile I have some breathing space to investigate why cyrus stops working.

I am seeing the following errors in /var/log/messages
:

May 16 09:12:30 galactica lmtpd[15608]: DBERROR db4: 60 lockers
May 16 09:12:30 galactica lmtpd[15645]: DBERROR db4: 60 lockers
May 16 09:12:30 galactica lmtpd[15645]: DBERROR db4: 60 lockers
May 16 09:12:31 galactica lmtpd[15635]: DBERROR db4: 60 lockers
May 16 09:12:31 galactica lmtpd[15640]: accepted connection
May 16 09:12:31 galactica lmtpd[15640]: lmtp connection preauth’d as postman
May 16 09:12:31 galactica lmtpd[15640]: DBERROR db4: 60 lockers
May 16 09:12:31 galactica lmtpd[15701]: accepted connection
May 16 09:12:31 galactica lmtpd[15701]: lmtp connection preauth’d as postman
May 16 09:12:31 galactica lmtpd[15730]: mystore: starting txn 2147484605
May 16 09:12:31 galactica lmtpd[15730]: DBERROR db4: 61 lockers
May 16 09:12:32 galactica lmtpd[15701]: DBERROR db4: 61 lockers
May 16 09:12:32 galactica last message repeated 2 times

I will appreciate if somebody has any idea what’s wrong.

May 16, 2008 at 11:50 am Leave a comment

Terminal colors

Default colors of files listed with ls command can be changed in /etc/DIR_COLORS file. For xterm the file is /etc/DIR_COLORS.xterm

Of course those values will be reflected globally. Each user can customize the colors individually by copying this file to .dir_colors in his home directory.

Example:
The folowing settings:

NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 00;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 41;33;01 # symlink to nonexistent file

Result in the following output of ‘ls -l’ command:
Terminal colors before the change

And then we have decided that directories should be listed as green:

NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;32 # directory
LINK 00;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 41;33;01 # symlink to nonexistent file

Result:
Terminal colors after change

April 22, 2008 at 4:24 pm Leave a comment

Reading BIOS information

Little handy command to read BIOS information from Linux level:

dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8

Sample BIOS reading from Dell 2950 running SLES10 SP1: here

April 1, 2008 at 2:48 pm Leave a comment

Find command – examples

Find command can do more than many of us could expect. Simple searches are obviously the most popular but as following examples show humble find can do a lot more:

1. search for a file
find . -name “filename”
2. don’t descend to other filesystems
find . -name “filename” -mount
3.list all directories
find . -type d
4. list all files
find . -type f
5. list all symbolic links
find . -type l
6. list all files more recent than filename
find . -newer filename
7. list all files that the userid doesn’t correspond to valid userid
find . -nouser
8. list all files that the groupid doesn’t correspond to valid groupid
find . – nogroup
9. search all core files and ask before deleting them
find / -name “core*” -ok rm rm{} ;
10. search all files and include the filenames in caution.txt
find / -perm 777 -fprint /tmp/caution.txt

11. search all .dat files bigger than 1M and older than 1 year
find /home -type f -name “*.dat” –size 1M -atime +365 -print
12. search all .c files and sort them
find /home -name “.c” -exec wc -l {} ; | sort -nr

For convienience I have created PDF version here.

March 20, 2008 at 10:45 am Leave a comment

What is the right linux filesystem?

While researching the filesystem performance for a customer a while ago I have come across val Henson’s presentation. It is good starting point for anyone deciding on best choice for a filesystem.
The structure of the presentation.
– Understanding your workload
– File system performance basics
– Differences between file systems
– Example workloads and file system choices
– Workload Q&A describe your workload
– Quick peek at future Linux file system development

Download PDF document here or find more useful stuff at http://valhenson.org/

March 10, 2008 at 11:28 am Leave a comment


Recent Posts

Categories