Need to extract numbers and create a comma separated list:
$ sed -e :label -e N -e ‘s/\n/, /’ -e ‘s/[ |]//g’ -e tlabel <<xxxx
> | 919 |
> | 1027 |
> | 1593 |
> | 1595 |
> xxxx
919,1027,1593,1595
Need to extract numbers and create a comma separated list:
$ sed -e :label -e N -e ‘s/\n/, /’ -e ‘s/[ |]//g’ -e tlabel <<xxxx
> | 919 |
> | 1027 |
> | 1593 |
> | 1595 |
> xxxx
919,1027,1593,1595
“Good” set of java parameters to run “generic” application like tomcat:
JAVA_OPTS=”-d64 -Xms512m -Xmx512m -XX:MaxPermSize=128m”
JAVA_OPTS=”-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true $JAVA_OPTS”
JAVA_OPTS=”-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:-TraceClassUnloading $JAVA_OPTS”
JAVA_OPTS=”-XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpOnCtrlBreak -XX:HeapDumpPath=/home/tomcat/snapshots $JAVA_OPTS”
These are not good but they are working options to enable jmxremote console.
JAVA_OPTS=”-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1888 -Djava.rmi.server.hostname=test.com $JAVA_OPTS”
To exit on OutOfMemoryError in jdk1.6:
Unix:
-XX:OnOutOfMemoryError="kill -9 %p"
Windows:
-XX:OnOutOfMemoryError="taskkill /F /PID %p"
JRockIT:
-XXexitOnOutOfMemory
I had a lot of troubles starting Oracle Weblogic 10.3g under linux (CentOS 5.2). It took anywhere between 5 to 20 minutes from the time I ran startup script to the point when Weblogic actually started. Here is typical log:
<Mar 12, 2009 12:35:34 PM EDT> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3 Fri Jul 25 16:30:05 EDT 2008 1137967 >
<Mar 12, 2009 12:46:37 PM EDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
Turns out Weblogic uses random number generator during start up. Because of the bug in java it reads ‘randomness’ from /dev/random. /dev/random is very good random numbers generators but it is extremely slow. It takes sometimes 10 minutes or more to generate one number. /dev/urandom is not that good, but it is instant.
Java somehow maps /dev/urandom file to /dev/random. That’s why default settings in $JAVA_HOME/jre/lib/security/java.security are useless.
Possible solutions:
1) Add “-Djava.security.egd=file:/dev/./urandom” (/dev/urandom does not work) to java parameters.
Worse but working solution is:
2) mv /dev/random /dev/random.ORIG ; ln /dev/urandom /dev/random
3) Best solution is to change $JAVA_HOME/jre/lib/security/java.security
Replace securerandom.source with
securerandom.source=file:/dev/./urandom
This problem does not happen under windows because it uses different implementation of /dev/random.
It takes seconds to start weblogic server now.
Nice little program that might be used in linux to find what files were open by the process. For example:
strace ls 2>&1|grep “open”
netstat -nlp will give you an idea.
[root@os]# netstat -nlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:9921 0.0.0.0:* LISTEN 10982/ora_d000_orcl tcp 0 0 10.10.10.10:1521 0.0.0.0:* LISTEN 12516/tnslsnr tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6561/sshd udp 0 0 127.0.0.1:1052 0.0.0.0:* 10920/ora_pmon_orcl
Backup job stopped with:
Device is BLOCKED waiting to create a volume for:
It means that bacula ran out of volumes or space on disk and want you to create new volume manually.
Use “Label”, enter new volume name, assign it to a pool.
Your job should continue automatically.
Instead of
find albums -name *.jpg -not -name *.sized.jpg -not -name *.thumb.jpg -not -name *.highlight.jpg -exec zip -r -1 album.zip {} ;&
use
find albums -name *.jpg -not -name *.sized.jpg -not -name *.thumb.jpg -not -name *.highlight.jpg -print| zip -1 album.zip -@
It will take 5 minutes instead of 5 hours on 500MB archive.
These are simple and often overlooked rewrite rules to generate Permanent Redirects for sister domains.
UseCanonicalName On
ServerName www.olegshpak.com
ServerAlias olegshpak.com
ServerAlias www.niteart.com
ServerAlias niteart.com
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
RewriteRule .* – [F]
RewriteCond %{HTTP_HOST} ^niteart.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.niteart.com$ [OR]
RewriteCond %{HTTP_HOST} ^olegshpak.com$
RewriteRule ^(.*)$ http://%{SERVER_NAME}$1 [R=permanent,L]
If your configuration requires you to set UseCanonicalName to Off then use a real server name instead of variable in RewriteRule.
Why is it important? Main reason is SEO. With permanent redirect search engines are not going to think that you have two or more different websites with the same content.
To disable this message you need to modify logging properties file.
If you have logging.properties in your tomcat/conf folder then make changes there. Otherwise modify jre’s file.
Add to the end of /usr/local/java/jre/lib/logging.properties this line:
org.apache.tomcat.util.http.Parameters.level = SEVERE
Restart tomcat.
The reason for this message is some problem with url’s parameters format, like && in the begining of parameters etc. It is harmless, tomcat will process parameters anyway.
Another nice feature to reduce ammount of information in catalina.out file is to redirect system output from catalina.out to web application log. Add swallowOutput=”true” to the context like this:
[root@u tomcat]# more conf/Catalina/localhost/ROOT.xml
<Context docBase=”/clients/client1″
privileged=”true” antiResourceLocking=”false” antiJARLocking=”false”
swallowOutput=”true”>
</Context>