As the title says, I have a number of cron jobs set up on my Java web application hosted on AppEngine standard environment, but one or two of them fail to run.
Examining the logs, I can see that the httpRequest for the ones that fail have 302 error code, indicating that the URL can't be found. The ones that work, return 200 as expected.
I can manually invoke the cron jobs' URLs and they work so it doesn't appear to really be a 302 problem. From the logs, Chrome sees a 200 response, but AppEngine sees 302:
The cron.xml file is in the correct place and works for the other jobs. this is the cron entry that's failing:
<cronentries>
<cron>
<url>/home/cron/boatactivity/</url>
<description>generate activities for boat movement</description>
<schedule>every 3 hours from 00:00 to 21:00</schedule>
</cron>
</cronentries>
And this is how it looks in the console:
I've checked an double checked the configuration and can't figure out what the problem is.
Any suggestions please?
Related
I recently updated my cron.yaml file and now my cron tasks fail with no entries in the logs.
It is acting like the java servlet at the url is not being run.
I can paste the url into a browser and the servlet runs fine.
My cron.yaml file:
cron:
- description: Daily revenues report
url: /revenues
schedule: every day 07:35
timezone: America/Denver
Using below deploycron.sh
PROJECT_ID='my-project-id'
gcloud config set project ${PROJECT_ID}
gcloud info
gcloud app deploy cron.yaml
Is there an error in my .yaml?
Is there a special task queue set up required?
Is some other configuration or permissions piece missing?
It was running fine last week. I have tried deleting and starting over to no avail.
https://console.cloud.google.com/cloudscheduler?project=project-id
Shows the job. Result column 'Failed'.
Logs 'View' link shows:
protoPayload.taskName="01661931846119241031" protoPayload.taskQueueName="__cron"
with no log entries.
Is __cron not automatic?
I am at a loss.
App Engine Standard. Java 8.
After installing the latest update of GCloud locally and re-running the deploy cron script. The cron jobs now run as before. 02/02/2021.
'Failed' means that the endpoint /revenues is not returning a success http status code.
Logs 'View' link shows: protoPayload.taskName="01661931846119241031" protoPayload.taskQueueName="__cron" with no log entries
Maybe don't use the premade filter, and just try filtering for /revenues or viewing all the logs at 07:35 am (when it was supposed to have run)
Is there an error in my .yaml?
if there was then gcloud app deploy cron.yaml would fail
Is there a special task queue set up required?
you shouldn't need to do anything, i didn't
I can paste the url into a browser and the servlet runs fine.
When you paste the url into the browser, is there any redirecting (like from /revenues to /revenues/) or anything that your browser is handling for you. Maybe /revenues is expecting there to be cookies present now.
What are there any special app.yaml or dispatch.yaml rules that /revenues would be hitting?
Is /revenues being handled by a service other than the default service?
I had a similar problem: CRON tasks fail without any logs.
The root cause was that the IP address of App Engine was blocked by the App Engine Firewall. Thus I had to update the allow-list, as described here: https://cloud.google.com/appengine/docs/standard/nodejs/scheduling-jobs-with-cron-yaml#validating_cron_requests
I started having the same problem a few days ago on my existing CRON schedules. I've tried everything including tearing my code down to the bare minimum and creating a new GAE project with the Hello World quick start. It still fails. Nothing useful in the logs and the UI just says 'Failed'. I'm pulling my hair out.
Sorry I don't have an answer to contribute but your post makes me think it's on Google's side. I know they're moving CRON jobs to Cloud Scheduler->App Engine Cron Jobs. My gut tells me it's a permissions issue related to this move and IAM. I'm really at a loss.
We have multiple App Engine Cron entries triggering our App Engine application, but recently we detected a decrease on the number of the processed events handled by one of the endpoints of our application. By looking at the App Engine Cron logs for this specific Cron entry on StackDriver, we found out that, during the days we invesgated (March 11-15), that are missing entries. Most of the missing triggers coincide through the days (12:15, 14:15, 16:15, 18:15, 20:15, 22:15, 00:15).
The screenshot below displays one specific day, and the red lines indicate the missing entries:
There are no requests with HTTP status code different than 200.
This is the configuration of the specific Cron entry (replaced some words with XXX due to business restrictions):
- description: 'Hourly job for XXX'
url: /schedule/bigquery/XXX
schedule: every 1 hours from 00:15 to 23:15
timezone: UTC
target: XXX
retry_parameters:
min_backoff_seconds: 2.5
max_doublings: 5
Could someone # GCP side take a look? The task name is 53751dd6a70fb9af38f49993b122b79f.
it seems like if the request takes longer than an hour, then the next one gets skipped (i.e. cron doesn't launch the next iteration if the current iteration is still running)
maybe do the actual work in a separate task and then the only thing the cron task does is launch this separate task
I want to run a cron for every 2 minutes interval, 0,2,4,6,8 .... each cron execution runs for 2 minutes.
I configured cron schedule with synchronized as below. But I still see scheduler is behaving as if synchronized not given.
Crons are scheduled at
0-2 First cron
4-6 Second cron
8-10 third cron
Cron scheduler is waiting for 2 minutes after last cron execution.
If I understand synchronized correctly, it is added to avoid this behavior.
Why this happening.
<cron>
<url>/cron/syncPrices</url>
<description>Fetch data from source and cache it in data store.</description>
<schedule>every 2 minutes synchronized</schedule>
</cron>
You can check the actual cron configuration for your application on the old GAE console in the Cron Jobs menu on the left. You're looking to confirm if synchronized (or its from 00:00 to 23:59 equivalent) is present for the respective job:
if synchronized is missing it's possible that the cron.yaml file wasn't uploaded/updated during the regular app upload - I noticed this to be the case with my multi-module (python) application. You have to specifically update the cron configuration using the update_cron option of your AppCfg utility.
if synchronized is indeed present and the unexpected behaviour continues you should open a support case with Google.
FYI It looks like 'synchronized' is no longer part of the cron.yaml documentation. I've reached out to Google via the documentation feedback link.
I've the following in cron.xml on my WEB-INF directory:
?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/?brtyuioacdwer</url>
<description>Load datastore</description>
<schedule>every monday 06:17</schedule>
<timezone>America/New_York</timezone>
</cron>
</cronentries>
But when the time comes to execute the shown URL nothing seems to happen as my datastore keeps the same, of course I've tested to call the URL from browser and it does its work nicely and I've uploaded new version of the app several minutes before it should be automatically executing. I don't know if there might be some problems with cron jobs when they try to write on datastore or if they are not the default version af the web application, so I'm asking for some guide.
Thanks for your attention.
(If this is not a question for SO, I will be gladly moved elsewhere)
I have a GAE backend that I want to start regularly with cron. With the help of other questions from SO, I set up backends.xml like this
<?xml version="1.0" encoding="UTF-8"?>
<backends>
<backend name="myBackend">
<class>B1</class>
<instances>1</instances>
<options>
<dynamic>true</dynamic>
</options>
</backend>
</backends>
and my cron.xml like this
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/doHardStuff</url>
<description>doing long running stuff</description>
<schedule>every 3 hours</schedule>
<target>myBackend</target>
</cron>
</cronentries>
And I upload it using mvn-gae (I am writing everything in java with maven) with goals gae:deploy gae:backends-list gae:backends-update
Everything loads fine and the long running stuff is done, however. Even after finishing everything, the dynamic backend still runs and eats my daily backend quota. I can see _ah/stop request in logs after the servlet finishes its job; however the backend still runs after that.
If I stop it manually in engine web console in Main -> Backends -> Start/Stop, it stops eating my quota, however, it won't run at a given time in cron and the cron job will fail.
What should I do? I want the backend to start at the given time and stop when the request is over and the machine is idle. I don't want it running at a different time.
It's working as it's supposed to. Dynamic backends are always "started" in the backends tab in the dashboard, which just means they can get requests and start instances if needed. This doesn't consume any quota.
When the backend gets a request it starts an instance using /_ah/start/ and consumes quota. When it doesn't have any requests to serve for some minutes it stops the instance with an /_ah/stop/ request.
To figure out if the backend instance is still running, change to the instances tab and select the backend "version".
Note that dynamic backends have a 15 minutes quota penalty, which is probably why the quota usage is higher than expected.
For dynamic backends, billing ends fifteen minutes after the last
request has finished processing.
http://developers.google.com/appengine/docs/python/backends/overview#Billing_Quotas_and_Limits
It seems like it takes them 15 minutes to be stopped, according to some pages online.
This seems possible, I will try it.