Back

[SOLVED] Cloud Function scheduling

  • 0
  • Functions
djcali
11 Apr, 2023, 03:25

Hello, I am interested in scheduling my function to run every night at a certain time. I see a section in the console that reads Update CRON Schedule I was looking through the docs and can't seem to find any information to get started. I never worked with CRON schedules before. Does anyone have an example of a schedule that I can see? Thanks.

TL;DR
The user had issues with scheduling their cloud function and was confused about the different time zones. Eventually, they realized that the time difference was causing the problem. They adjusted the cron settings and the function executed as expected. The issue was solved.
Arth
11 Apr, 2023, 03:34
djcali
11 Apr, 2023, 03:41

Thanks!

djcali
11 Apr, 2023, 04:07

What I am trying to do is this: I have a collection made up of Appointments with the attributes ApptDate, ApptStartTime, ApptEndTime, isEditable and some other details about the Appointment I want to have a function run every night to check if an appointment is past the ApptEndTime, if it is make that appointments isEditable field to false. Since there is a limitation of 25 records I can query at a time, is the proper way to do this is get the total documents from the listDocuments endpoint and just do a loop and use the updateDocument endpoint to update the records as needed? Not sure if functions fall into this exception I got from the updateDocument doc This endpoint is limited to 120 requests in every 1 minutes per IP address, Any advice?

Arth
11 Apr, 2023, 04:23

executing functions won't hit rate limit since they use server-side sdk authenticated with an API key

Arth
11 Apr, 2023, 04:23

ratelimit is only for client apps

djcali
11 Apr, 2023, 04:25

Ok great. So will my logic work getting the total docs and then just using a loop and get the next 25 docs if needed. is that way ok to do? or is there a better way. Thanks again.

Arth
11 Apr, 2023, 04:30

that seems like the best way rn considering there's no way to batch update as of now

joeyouss
11 Apr, 2023, 08:04

Hope these help you - if not, feel free to post your questions as and when you feel stuck

djcali
11 Apr, 2023, 16:47

Thank you for this. I have the cron schedule for my functions set as 17 12 * * * to execute at 12:17 but it did not work. Not sure why. I did look at your example from here https://dev.to/appwrite/30daysofappwrite-cloud-function-with-cron-258c And I have it set up that way. Any other suggestions?

Do I have to set anything in this section? Update Events ?

djcali
12 Apr, 2023, 20:19

It works just the time difference from server and my local machine. Sorry.

djcali
12 Apr, 2023, 20:19

[SOLVED] Cloud Function scheduling

Drake
12 Apr, 2023, 20:37

I would assume the time is in UTC. is that right? or is it the actual server timezone?

djcali
12 Apr, 2023, 20:38

I just can not wrap my head around all the different times. When I log into my ubuntu server and type date I get back the same time of my local machine Wed Apr 12 16:39:18 EDT 2023 but appwrite must be in UTC.

djcali
12 Apr, 2023, 20:45

My function cron schedule says 11 15 * * * but then when I hover over the time icon on the main functions page i get Next Execution Apr 13, 2023 11:11

Drake
12 Apr, 2023, 21:06

What version of Appwrite are you on?

Drake
12 Apr, 2023, 21:07

and what's your time compared to UTC?

djcali
12 Apr, 2023, 21:41

My time is 17:41 and UTC is 19:41

djcali
12 Apr, 2023, 21:42

Looks like I am -4:00

Drake
12 Apr, 2023, 21:56

so that looks right then. the cron is in UTC and the next execution is your local time

djcali
12 Apr, 2023, 21:57

Yep. I just have to adjust my cron settings and keep in mind of the 4 hr difference.

djcali
12 Apr, 2023, 21:59

Just tested the function and it ran as expected with the adjusted cron. Thanks. This thread is officially solved. haha

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more