Skip to main content

Posts

Showing posts from February, 2012

CronJob

Example Example: Insert a record into a database every one minute. 1. Create a .sh file ----insertsms.sh--- mysql -N -u root -e "use database; INSERT INTO table1 (project_id,feedback_id, text)VALUES (5,201,'Thank you,  I am ALWAYS happy with the service I receive from .......');" 2. Run command in the command line # crontab -e 3.   Append the following entry: 0-59 * * * * /root/ insertsms  .sh save the file More Examples To run /path/to/command five minutes after midnight, every day, enter: 5 0 * * * /path/to/command Run /path/to/script.sh at 2:15pm on the first of every month, enter: 15 14 1 * * /path/to/script.sh Run /scripts/phpscript.php at 10 pm on weekdays, enter: 0 22 * * 1-5 /scripts/phpscript.php Run /root/scripts/perl/perlscript.pl at 23 minutes after midnight, 2am, 4am ..., everyday, enter: 23 0-23/2 * * * /root/scripts/perl/perlscript.pl Run /path/to/unixcommand at 5 after 4 every Sunday, enter: 5 4 * * sun /p...

How to install JSVC on Linux WidenHome Log | WidenHome Log

How to install JSVC on Linux WidenHome Log | WidenHome Log In our team, we have a lot of Java standalone applications which should be run as daemon on Unix/Linux system, and we found JSVC is the best choice for us to wrap Java programs to daemons. This article records the steps on how to install JSVC executable on Linux, which is our stage/prod environment. Download JSVC source package First of all, we need to download JSVC source package from this URL: http://commons.apache.org/daemon/download_daemon.cgi , for example, I downloaded commons-daemon-1.0.5-src.tar.gz file. Or, download it via wget: wget -c http://apache.etoak.com/commons/daemon/source/commons-daemon-1.0.5-src.tar.gz Build JSVC executable Unzip the source package and build JSVC executable. chmod 755 commons-daemon-1.0.5-src.tar.gz tar zxvf commons-daemon-1.0.5-src.tar.gz cd commons-daemon-1.0.5-src/src/native/unix Before building the JSVC executable, please make sure you have set JAVA_HOME variable correctly. And make sur...

Log4j Configuration

First, include  Log4j   jar file in your project (e.g. log4j-1.2.8.jar) From  http://www.javabeat.net/tips/82-baisc-steps-to-configure-log4j-using-xml-and.html Configure Log4j This example demonstrated how to configure  Log4j  setup using the Proerties file and  XML file . These are the two most widely used techniques for configuring the  Log4j  for your application. But, in the recent days configuring with  properties files  are considered to be old technique and recommended using  XML . This example program uses simple satndalone java program for running the example. But, in most of the  project  scenarios it will be used in the web application. However the configuration file will be the same. log4j.properties # Set root logger level to DEBUG and its only appender to Appender1. log4j.rootLogger=INFO, Appender1,Appender2 # Appender1 is set to be a ConsoleAppender. log4j.appender.Appender1=org.apache...

org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcesso

org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor 这个错误是tomcat的lib文件夹jar包和项目的lib文件下的jar包冲突了 把项目下lib文件下和tomcat的jar的重复的全部删除。错误终于被搞定。 注意,如果你是先建flex工程然后转成web形式的,请把项目中tomcat类库删除,不然还会冲突 第二种解决办法 修改了tomcat里的context.xml文件,在context 元素下添加     

Manipulating Files in Java 7

From  Manipulating Files in Java 7 The following is a modified snippet from a draft of  The Well-Grounded Java Developer . It gives you a quick taster of how much easier it is to manipulate files in Java 7 than in previous versions. By using the new  Files  class and its many utility methods, you can perform the following operations on files with only a single line of code: Create Delete Copy Move/Rename TIP  A quick note on  Path . This post assumes you have some passing familiarity with the new Java 7  Path  class, if not here’s a quick introduction!  Path  is the logical abstraction of a location on the file system, e.g.   c:\  is a  Path  as is  ../foobar.txt Let’s start by looking at the creation and deletion of files. Creating and Deleting files By using the simple helper methods in the  Files  class you can create files and delete them easily as well. TIP  If you are runn...