Saturday, September 27, 2008

Kylie A – Sleep

Delete old logs files in Linux

A common task of maintaining Linux operating systems (and that extends to most operating systems based on or clones of Unix) is cleaning the log files. Both the operating system as a database engine few data and proprietary processes can generate large amounts of log files. In the long term, it is necessary to remove these files as we occupy space, have become obsolete and we tend to complicate the search.
 Therefore, based on the original publication "List / Delete files by date in Linux as we can see from the shell to search for and delete old files. Needless to say, that the commands listed below are candidates to be part of a shell script and is likely to be executed by cron. 

Well, enough of words and see some practical examples:
 Find files updated three days ago in the current directory: 

cd / var / log
find-name \\ *. log-mtime +3
 Search 
updated files until three days ago in the current directory and delete them:
find. -Name \\ *. log-mtime +3-exec rm {} \\;

Find the updated files back one day and show its full path:
find / var / log / [az] * \\ *. log-mtime +1
As in the second case, if we delete the files returned by the previous command:
find / var / log / [az] * \\ *. log-mtime +1-exec rm {} \\; addition, we can refine the search more by using the argument-mmin-mtime instead of:

*-mtime n, search for files modified n * 24 hours ago (n days ago) PS: This line can be used to delete old backups if we set a cron to backup a database or other files as tgz. etc.

find *. tgz-mtime +6-exec rm {} \\; (


eliminate having a week old)


source (http://www.luchoedu.org/)






Spot Dangers Worksheet

What are the SQL transactions?








are a set of SQL statements that have the quality to run as a single unit that is running or not running all or none.
A tables
able to support transactions are called
ACID (Atomicity, Consistency, Isolation
, Durability)
English (Atomicity, Consistency, Isolation & Durability)




Atomicity: =>
Something that can not be divided, I mean all queries are treated as one and they only run when all are correct in the event of a mistake does not run anything. Consistency: => This is linked to referential integrity, ie can only be write valid data in compliance with the declared data types and referential integrity.

Isolation: => Each transaction is executed independently of other transactions or rather one after another, after these transactions are executed (successful or wrong) the changes are visible to other users. Durability: =>

When a transaction completes successfully the changes become permanent.
  1. Example

  2. Let the following example how important it may be a transaction.

  3. Suppose that two vendors store availability consult the LCD and only have one is stock (as these are hot) to make a sale and one is a TV in stock.

    only with SQL

    First

Vendor 1

: SELECT stock FROM TV;

Seller 2: TV

SELECT FROM stock;

Seller

1: UPDATE

TVs SET stock = stock -1;

Seller 2: UPDATE

TV SET stock = stock -1;

SELECT First to make each vendor will see on your screen that is available 1 television.

The seller 1

sell the TV leaving the stock to 0, then the seller 2

does not know that the TV has been sold and will sell TV (think there is stock) and the stock will be -1 and the latter has been sold by the seller 1

. If real life was a customer will have to wait longer than normal to reach your TV. Now same Transactions Seller 1: START TRANSACTION; Vendor 1

: SELECT stock FROM TV;


Seller 1: UPDATE

TV SET stock = stock -1;

Seller

1: COMMIT , (running)

Seller 2:

START TRANSACTION;

Seller 2:

SELECT stock FROM TV;

Seller 2: ROLLBACK; (out of the transaction without doing anything more)

Seller 2: Tip client not availability and asks if you want to buy and wait a few days until there is stock again.

As we have seen the operations were computer allows data consistency after the first vendor to finish the operation performed seller 2 queries. Example 2 (Something more work)

This example shows how to perform operations in a transaction have 1 table called departments with the following structure and records


CREATE TABLE `departments` (

CODIGODEP `` INTEGER (11) NOT NULL DEFAULT '0 ', `NOMBREDEP

` VARCHAR (100),
BUDGET `` INTEGER (11),

PRIMARY KEY (`CODIGODEP`) ) ENGINE = InnoDB

INSERT INTO `departments` (`CODIGODEP`, `NOMBREDEP`, `Budget`) VALUES (1, 'Computer', 300000), (2, 'Personal', 200000), (11, 'Quality', 150 000), (13, 'Security', 450,000), (56, 'HR', 900,000), (77, 'Administration' 1500000);


and now create a new departamentos2 table and assign 30% of the money from the budget of each department departamentos2 table, ie departmental budget subtract 30% of its budget and assign to departments departamentos2 table. (The structures are equal and incuse keep the same codes and names of departments)




departamentos2 `CREATE TABLE` (`CODIGODEP

` INTEGER (11) NOT NULL DEFAULT '0 ', ` NOMBREDEP `VARCHAR (100), BUDGET` `INTEGER (11),
PRIMARY KEY (` CODIGODEP `)
) ENGINE = InnoDB



now

transactions


START TRANSACTION;

departamentos2 insert into `select`

codigodep, nombredep, budget departments * `from` 0.30; September update departments budget = budget - (budget * 0.30 ) COMMIT;




The result has been a table of all records of departments 1 and budgets of the two tables have been properly modified by adding and subtracting 30% respectively.






This will prevent any other user is modifying the table when performing the operation departments
Jlara


Friday, September 26, 2008

How Fast Does A 4hp Motor Go

Install Java Development Kit (JDK) and Java Runtime Environment (JRE) in Ubuntu Linux console

This short tutorial will explain how to install the correct JRE version of Linux, because when we will download files from the Sun

page there are so many that sometimes do not know what to install. Installation

tested ubuntu 7.10 desktop, Ubuntu 8.04 desktop and server.

Packages needed:


=>
sun-java6-bin

: Sun Java Runtime Environment (JRE) 6 =>
sun-java6-demo
: Sun Java Development Kit (JDK) 6 demos
=>
sun-java6-jdk => sun-java6-jre : Sun Java Runtime Environment (JRE) 6


Install Sun Java 6

Open a shell (terminal) and type the following to install JDK and JRE:
  1. $ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
  2. here displays a message indicating all the dependencies of packages to install, press S to accept.
  3. Default install Java version
  4. Ubuntu Linux comes with update-java-alternatives utility updates all the alternatives that belong to a development kit for Java. To select, Sun JVM as provided type:
  5. $ sudo update-java-alternatives-s java-6-sun
also need to edit a file called / etc / jvm
. This file defines the default search order system for jvm (java virtual machine). Each list of JVM in JAVA_HOME should be in this file. The default system JVM is the first one available from top to bottom. Open
/ etc / jvm


$ sudo vi / etc / jvm

sure to add
/ usr/lib/jvm/java-6-sun
at the top of the list JVM.
The file should read:


/ usr/lib/jvm/java-6-sun

/ usr / lib / jvm / java-gcj
/ usr / lib / jvm / ia32-java-1.5.0-sun
/ usr/lib/jvm/java-1.5.0-sun

/ usr

Save and close the file. (Esc: wq)

Setting environment variable
also need to set JAVA_HOME and PATH (system wide) configuration . Open your $ HOME /. Bash_profile or / etc / profile:
$ vi $ HOME / .bash_profile
Add line:
export JAVA_HOME = / usr/lib/jvm/java-6-sun export PATH = $ PATH: $ JAVA_HOME / bin

Save and close the file. (Esc: wq)

Test your new JDK

Type the following command to display the version:
$ java-version
should display a message like this
:


java version "1.6.0_03"

Java (TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot


(TM) Server VM (build 1.6.0_03-b05, mixed mode)

(If you see this happiness you already have everything you need installed)


First program (Java Hello World)
$ vi holaMundo.java

Type the following code: public
   
class HelloWorld {



public static void
main (String

[

]

args) {
       
System . out.println ( "Hello, World!" ) ; }} Save and close the file. holaMundo.java compile and run the program by typing two commands:
holaMundo.java $ javac $ java HelloWorld out: Hello, World!