This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
An IDE is no substitute for an Intelligent Developer.
Joined: May 05, 2008
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Write a cron job to call struts action class