11/25/2011

Linux Crontab

Crontab is a tool for adding periodic tasks to a specific user. You can edit the crontab with the following command and add your own periodic tasks.
crontab -e
Crontab entry format is as below:
* * * * * [command to be executed]
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
And here is a sample crontab entry:
0 * * * * /bin/ksh /opt/oracle/report/scripthourly.sh
0 * * * * /usr/bin/find /opt/oracle/report/mdsphourly/ -name "*.csv" -ctime +1 -delete

11/13/2011

GraphViz Java

I will introduce Java api for GraphViz. In order to use this api, these are the steps you have to follow:

  • You have to first download graphviz application for your OS.
    You will need dot.exe location in order to run the application correctly.
  • In the java api link, you should download the source file. (GraphViz.java)
  • Include this source to the project.
  • You should change the following variables according to your preference and installation.
    TEMP_DIR may be any folder.
    DOT is the location of the dot.exe in graphviz installation folder.
  • Write this main method in any class and test your installation and output.
    import java.io.File;
    
    public class GraphVizExample {
        public static void main(String[] args) {
            GraphViz gv = new GraphViz();
            gv.addln(gv.start_graph());
            gv.addln("A -> B;");
            gv.addln("A -> C;");
            gv.addln(gv.end_graph());
    
            String type = "gif";
            File out = new File("D:/out." + type);
            gv.writeGraphToFile(gv.getGraph(gv.getDotSource(), type), out);
        }
    }
    
  • This application will generate a graph to the file D:/out.gif
  • The output image should be:
  • You can generate more complex graphs by applying the dot language specification.
You should change some functions for example GraphViz.start_graph() function to change the graph type.