Komal, First let's figure out what you want to run. You could connect to the URL that calls your Struts action. You could call a Java class with a main method that calls your Struts action.
This means the first step is to come up with one line that runs what you want. It could be "java MyProgram" or a UNIX script/program. wget allows you to make a http connection which would connect to the URL.
Once you have that working, the link Ben provided shows how to set up a cron job.
Just in case there are people who missed the point:
You cannot "call a struts action class", via crontab or not. Struts is a web application framework, and struts action classes are defined in terms of that framework, so what you actually would need to to is invoke the framework.
Making a long story short, that means that you have to make a web request to the server containing a Struts app which employs the action class. You can use tools like wget or curl to do that. In fact, I'm in the process of setting up a cron job to pull in a morning newspaper (PDF) on a daily basis using that technique right now. It can be as simple as this:
(I hope the forum software didn't break that into 2 lines.)
One of the reasons why it's considered bad practice to put business logic into Struts action processors (or JSF backing beans) is exactly because you might want to be able to invoke those business functions outside of the original framework.
For those of your who Already Knew All This, I apologize. But I've discovered that enough people don't realize things like this have to be allowed for that I felt obliged to point it out explicitly.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: May 05, 2008
subject: Write a cron job to call struts action class