Arquivo do Autor

Ubuntu / Linux desligando Wireless quando usa Bateria

Praticamente sempre que desconecto meu notebook (Thinkpad T430) da tomada, e deixo somente na bateria, o Wireless torna-se instável e é desligado. Quem faz esse desligamento é o utilitário /usr/sbin/pm-powersave. Você pode constatar isso efetuando o comando “ls -lrt /var/log” assim que o evento ocorrer. Verifique as ultimas linhas dos logs modificados e vai achar o vilão!

Para resolver, basta executar o comando:

sudo /usr/sbin/pm-powersave false

Você deve também criar um arquivo vazio em /etc/pm/power.d/wireless , dessa forma, o powersave não desligará o Wireless.


Categorias:Linux Tags:, , ,

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!