1. To find a process running in a port in linux
sudo netstat -lpn |grep :port_numberEg:
sudo netstat -lpn |grep :9001
Sample Output:
tcp 0 0 :::9001 :::* LISTEN 1070/java
2. To kill a process running on a particular port in Linux
sudo kill -9 processidEg:
sudo kill -9 1070
3. Select varchar as timestamp in PostgreSQL
select to_timestamp(column_name, 'DD-MM-YYYY hh24:mi:ss') from table_name4. Unzip a file in Linux
cd path_to_directory_containing_fileunzip file_name
5. Log of tomcat is found at
/tomcat/logs/catalina.out6. Rename a table in postgreSQL
ALTER TABLE old_table_name RENAME TO new_table_name;7. Disable logging in Java Xerces (“[Fatal Error] :1:1: Content is not allowed in prolog.”)
Setting the ErrorHandler to null suppresses the Fatal Error print line.parser.setErrorHandler(null);
Eg:
DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dBF.newDocumentBuilder();
builder.setErrorHandler(null);
Source: http://stackoverflow.com/questions/1575925/disable-logging-in-java-xerces-fatal-error-11-content-is-not-allowed-in-p
8. Display today's date in PostgreSQL
select now();9. Extract hour from timestamp in PostgreSQL
select (extract(hour from to_timestamp(column_name, 'DD-MM-YYYY hh24:mi:ss'))) from table_name;No Cloud is so Dark that the Sun can't Shine Through!!
No comments:
Post a Comment