Using SHC to initiate a daily server CRON

I need to initiate a CRON which in turn triggers a daily server utility method. This routine needs to run daily whether or not any users are active, independent of users.

Several weeks ago Jan Aleman recommended SHC as the way to go.

Morley:
I currently have a startup script running just fine in my isolated development environment. However I believe some routines should run only when the server is launched, such as a midnight Cron scheduler which does a global reset on all incomplete task records, rolls over tasks scheduled for completion yesterday and reschedules them for today.

Jan Aleman:
You can use deeplinking to a method for this by executing a URL in your cron. The url can launch a (headless) client and perform the script you indicate through the URL (2.2 and later, see 2.2 release notes for details on deeplinking to a method)

I’ve not been able to locate the 2.2 release notes Jan references (awaiting 2.2’s final release?). The above is the only place “deeplinking” is used in Servoy Talk, haven’t seen it anywhere else.

I’m just getting my toes wet with SHC. For the time being this is all I want to do with SHC – establish a CRON which will run a method daily shortly after midnight independent of any end user. Anyone have pointers on this?

In the release notes of the first beta of 2.2 at
http://forum.servoy.com/viewtopic.php?t=3546

you will find this:
[enh]-http://<servoy_server_ip>/servoy-client/servoy_client.jnlp?solution=crm&method=showOrder&argument=10444&rnd=12302 will only open a client when no one is running that solution, otherwise the running client will execute this method (will only work in one local network!)

Note that that launches a normal client, so you must run it on a server with GUI.

You can also go headless in which case you will create:

  1. the method inside servoy that does the work
  2. a jsp page in Servoy/server/webapps/root that contains something like this:
<%@ page import = "java.util.*" %>
<%@ page import = "com.servoy.j2db.server.headlessclient.*" %>
<%@ page import = "com.servoy.j2db.dataprocessing.IDataSet" %>
<%@ page errorPage="errorpage.jsp" %>
<%
	ISessionBean servoy_hc = (ISessionBean)session.getAttribute("servoy");
	if (servoy_hc == null)
	{
		servoy_hc = HeadlessClientFactory.createSessionBean(request,"SOLUTION");
		session.setAttribute("servoy",servoy_hc);
	}
	boolean ok = servoy_hc.setMainForm("MAINFORM");
String result = (String)servoy_hc.executeMethod(null,"DOSTUFF",null);
%>

SOLUTION = the solution you want to connect to
MAINFORM = the form you want to use as main form, prob the one that maintance method is attached to
DOSTUFF = the name of the method you want to execute[/code]

Thanks, appreciated.

Supplemental. Does the computer triggering the headless client need to be kept running, i.e. that instance of a client use kept running in order for the Cron to keep running?

If so, this becomes a vulnerability. I need this utility function to run daily regardless.

Kind regards,