How to create a scheduled custom function

How to create a scheduled custom function

Hi Team - I am aware there is a Schedules in CRM so we can run daily custom functions. I tried writing a custom function but I am not successful in running a Schedule.

I need to run a Schedule so that my Ageing in Days field for Deals gets updated on a daily basis. Can someone point me to the correct syntax for running Schedules?

I tried running a workflow that triggers a custom function during modified time but it only runs once. I need that Ageing in Days to be updated on a daily basis. Any help would be greatly appreciated. Thanks in advance.

For reference, here is my code:
resp = zoho.crm.getRecords("Deals");
for each  ele in resp
{
if(ele.get("Due_Date") != null && ele.get("Stage") != 'Collected' && ele.get("Probablity") == 100)
{
dealid = ele.get("id");
duedate = ele.get("Due_Date");
ageing = duedate.days360(zoho.currentdate);
mp = Map();
mp.put("Ageing",ageing);
update = zoho.crm.updateRecord("Deals",dealid,mp);
}
}

Am I right in using getRecords or should I use SearchRecords? Is it possible to get or search of Deals records?