Adding a scheduled task to Cron at Linux

Lets suppose that you have to run some task (a script for example) called every day at 6 and 12. You can use Linux Cron to schedule it.

Enter the command crontab -e to edit your cron schedule, then, add the lines:
00 6 * * * //
00 12 * * * //

Then, just save the file and voilà!

Cron its very flexible, you can configure minutes, seconds, days, months and years, and create complex schedules!


Process check script for Linux

Sometimes I need to keep checking the some process is running in my servers. So, I created the following script and add it to Crontab. If I have problems, Ill receive an email.
This can be useful to someone!
In my example, Im searching for a process called zookeeper.

ZK=`ps aux | grep zookeeper | grep -v "grep" | wc -l`

if [ $ZK -ge 1 ]
        echo "ZK is Running"
        echo "ZK is not Running" | mail -s "Zookeeper is not running - $SERVER"
Categorias:Linux Tags:, , , ,

Disk Space script for Linux

Sometimes I need to keep checking the disk space at my servers. So, I created the following script and add it to Crontab. If I have problems, Ill receive an email.
This can be useful to someone!

# In my case im interested in a specific partition /opt/XYZ
SPACE=`df -h | grep /opt/XYZ | awk '{print $4}' | awk -F % '{print $1}'`

case $SPACE in
        echo "Disk space > 90 %, please check" | mail -s "Disk Space problem",;;
        echo "Disk Full, please check" | mail -s "DISK FULL",;;
Categorias:Linux Tags:, , , ,

Adding DB2 jdbc drivers to a Maven Java project

You need to get the DB2 drivers, in my case db2jcc.jar and db2jcc_license_cu.jar, then, drop it to a folder at your file system, also, in my case I created a folder /opt/driveDB2 and drop the 2 files there.

Then, run the mvn install command, like in my examples (pay attention in your Version):

mvn install:install-file -Dfile=/opt/driveDB2/db2jcc.jar -DartifactId=db2jcc4 -Dversion=10.1 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

mvn install:install-file -Dfile=/opt/driveDB2/db2jcc_license_cu.jar -DartifactId=db2jcc_license_cu -Dversion=10.1 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

At your project, just add the following lines to the pom.xml file:



Voa lá!

Categorias:DB2 / Banco de dados, JAVA Tags:, ,

Java + JDBC: imprimindo informações de tabelas

Preciso pegar as informações das tabelas/colunas nas quais fiz uma query, e sempre esqueço… Fica a dica aqui com um código bem bobinho. sugestões são bem vindas.

		Statement stmt = connection.createStatement();
		ResultSet rs = stmt.executeQuery("SELECT * FROM TABLE FETCH FIRST 10 ROWS ONLY");

		ResultSetMetaData rsmd = rs.getMetaData();
		int columnCount = rsmd.getColumnCount();

		// The column count starts from 1
		for (int i = 1; i <= columnCount; i++ ) {
		  String name = rsmd.getColumnName(i);
		  System.out.print(name + "|");
		while ( {
			String toPrint = "";
			for (int col = 1; col <= columnCount; col++) {
				toPrint += rs.getString(col) + "|";

Creating a collection in IBM Watson Explorer crawling from Database

Perform a database Craw from a collection its something very common. With IBM Watson Explorer this is something very easy to do. In my example, Ill create a collection and will perform a simple query in a IBM DB2 database, but, the steps will be very similar for other databases, you just need to keep in mind that you will need the correct driver.

1- Put the driver in place:

Get the database jdbc and put in the correct folder, usually it is something like /opt/IBM/dataexplorer/WEX-11_0_2/Engine/lib/java/database/.

2- Create the collection copying defaults from default:


3- Add a new seed, this is where your collection will get data:


4- Choose Database:


5- Enter your database settings and the query that will be performed:


6- Its done, now you can test:


7- This can take a while depending on your query and connection, but when it finish, it will show some rows that the query returned in the following format. To see some row data, click Crawler XML:


8- Here is your data:


9- Now that we see that its working, you can start your craw. This step will feed your collection and can take a good time depending on your amount of data:


10-You must see Craw activity:


11- You can query your collection now to test, just enter your term and click search in the left options:


12- You will see something like this:


Thats it, you have created a collection that get data from Database!

Training your ontolections at IBM Watson Explorer

Ontolection Trainer its a nice stuff that people who are using ontolections to Improve the Queries at Watson Explorer need to know. This utility help us to analyze text body and create Thesaurus files, that can be used to create ontolections. Also, you can extract key-phrases or Acronyms that you can use with query-modifier and at some ontolection.

If you don’t know NLQ capabilities at Watson Explorer (WEX) or don’t know what is a Ontolection, I recommend that you read my 2 posts:

Backing to Ontolection Trainer, at NLQ folder (/opt/IBM/dataexplorer/WEX-11_0_2/Engine/nlq in my case) from your WEX installation (since rel 11.0.1), you can find the jar file ontolectiontrainer.jar. Obviously you will need Java to run it. Make sure that the JAVA from WEX installation are configured at your path.

The utility have several arguments, but, the basics are:

  • the type of extraction
  • the corpus that you will use: The corpus are your text file. In my case, I have a file with 1000 Resumes that Ill use to train WEX (RESUME_TEXT_1000.TXT ).
  • the pear file: Pear file consist in the dictionary that the trainer will user to extract terms.
  • the output path: Where it will create the file.

I have used a file called blacklist containing the words that I want to be ignored.

You can have problems with CPU and Memory utilization, for this cases, there are parameters to setup the number of iterations that trainer will do.

To be very objective, here is my commands:

  • To extract the ontolection:

java -jar ontolectiontrainer.jar –trainOntolection –corpus RESUME_TEXT_1000.TXT –pear /opt/IBM/dataexplorer/WEX-11_0_2/Engine/data/pears/en.pear –blacklist blacklist –outputPath generatedOntolection_1000

  • To extract Acronyms:

java -jar ontolectiontrainer.jar –extractAcronyms –corpus RESUME_TEXT_1000.TXT –pear /opt/IBM/dataexplorer/WEX-11_0_2/Engine/data/pears/en.pear –blacklist blacklist –outputPath generatedOntolectionAcronyms_1000

  • To extract Phrases:

java -jar ontolectiontrainer.jar –learnPhrases –corpus RESUME_TEXT_1000.TXT –pear /opt/IBM/dataexplorer/WEX-11_0_2/Engine/data/pears/en.pear –blacklist blacklist –outputPath generatedOntolectionPhrases_1000

For more reference: