Thursday, May 21, 2009

Add a startup script

/sbin/chkconfig --add sshd

Thursday, May 7, 2009

Read about

Lucene
JMX
JDNI (?)

DTO - data transfer object

Hibernate -Bags

Thursday, March 26, 2009

Find files created yesterday or before.

# create a file that has a timestamp of just after midnight today
touch -t `date +"%Y%m%d"0001.01` /tmp/just_after_midnight_today

# find files older than today
find /path/to/dir/ -maxdepth 1 ! -newer /tmp/just_after_midnight_today

Thursday, August 28, 2008

Archive last 7days data

find -type f -mtime -7 -print | xargs tar cvf to_test.tar

atime (access time) last time file was accessed
ctime (change time) time inode info changed owner, group, permissions or number of links.
mtime (modification time) time contents of file change

Wednesday, August 6, 2008

Redhat Hardware info

Info from:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1218051306170+28353475&threadId=956927

you can collect the system information using following build-in os command.

# dmesg|grep -i cpu
# cat /proc/cpuinfo
# cat /proc/meminfo
# dmesg|grep -i memory
# cat /proc/scsi/scsi
# cat /proc/pci

# cat /proc/cpuinfo|grep "model name"
# cat /proc/meminfo|grep "MemTotal:"

Get redhat release version
[epictide@fezzik bin]$ cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 7)

or you can use 3rd party software to know the system hw configuration. such as
1. lshw, URL: http://ezix.sourceforge.net/software/lshw.html
2. cfg2html-linux, URL: http://www.cfg2html.com/

you can also study from books or redhat official provide documents at following
http://www.redhat.com/docs/

Tuesday, June 10, 2008

Loading a properties file

stolen from http://www.spychalski.de/recipe-6.html


A property file called test.properties in the classpath.

URL url =  ClassLoader.getSystemResource("test.properties");
Properties p = new Properties();
p.load(new FileInputStream(new File(url.getFile())));

System.out.println(p.getProperty("my.property"));


Other method using classpath


It is best to put the properties file in the server's pre-made classpath. You will forget about changing the classpath later on and when you upgrade/change you will get frustrated :)

Anyway, the application's classpath starts in the WEB-INF/classes directory. If you put your propertied in there, the you could use
getClass().getClassLoader().getResourceAsStream(propertyFileName);
to get at it.

If you put it in the same directory as your class (in the class' package) then you could use
getClass().getResourceAsStream(propertyFileName);



Tuesday, February 19, 2008

Increase number of file handles.

vi /etc/security/limits.conf

add:
tomcat soft nofile 2048
tomcat hard nofile 2048