title: Setting up Cron.yaml in Google App Engine to work with files in Google Cloud Bucket. (python)
body: <p>I am using the Google App Engine to host a flask website.
  <em>Standard environment
  Python with flask app</em></p>
  <p>Basically, I have a <code>main.py</code> that has the script the public website runs on.
  I now want to create a separate tasks.py script to run the jobs I need to do daily at a scheduled time. For trials, I am trying to delete a file currently in my bucket. <code>main.py</code>, <code>app.yaml</code>, <code>cron.yaml</code>, and <code>tasks.py</code> are NOT inside the static folder. Many answers in stack are now old (2012 etc) and I literally do not know how to troubleshoot crontask errors in the google app engine.</p>
  <p><strong>Directory system</strong></p>
  <ul>
  <li><p>main_workspace</p>
  <pre><code>   - main.py
  
     - app.yaml
  
     - cron.yaml
  
     - tasks.py 
  
     - static 
  
     - templates
  </code></pre>
  </li>
  </ul>
  <p>app.yaml</p>
  <pre><code>entrypoint: gunicorn -b :$PORT main:app --timeout 0
  
  env_variables: 
  (not revealed here, but used and works for main.py)
  
  handlers: 
    - 
      static_dir: static
      url: /static
    - 
      static_dir: stylesheets
      url: /stylesheets
   
   -
      url: /tasks.py
      script: auto
  
    
  
  runtime: python37
  </code></pre>
  <p>cron.yaml</p>
  <pre><code>cron:
  - description: &quot;daily summary job&quot;
    url: /tasks.py
    schedule: every 1 minutes from 21:32 to 00:00
  </code></pre>
  <p>tasks.py</p>
  <pre><code>from google.cloud import storage
  
  def delete_blob(bucket_name, blob_name):
      &quot;&quot;&quot;Deletes a blob from the bucket.&quot;&quot;&quot;
      bucket_name = &quot;pre_processed_bucket&quot;
      blob_name = &quot;rundata_AJA3_1_alyssa.txt&quot;
  
      storage_client = storage.Client()
  
      bucket = storage_client.bucket(bucket_name)
      blob = bucket.blob(blob_name)
      blob.delete()
  
      print(&quot;Blob {} deleted.&quot;.format(blob_name))
  </code></pre>
  <p>The error looks something like this:</p>
  <pre><code>*2020-11-03 23:37:50.886 HKT GET 404 378 B
  2.2 s AppEngine-Google; (+http://code.google.com/appengine) /tasks.py
   
  0.1.0.1 - - [03/Nov/2020:23:37:50 +0800] &quot;GET /tasks.py HTTP/1.1&quot; 404 378 - &quot;AppEngine-Google; (+http://code.google.com/appengine)&quot; &quot;actalab-site.et.r.appspot.com&quot; ms=2202 cpu_ms=2704 cpm_usd=4.2244e-8 loading_request=1 instance=00c61b117c61a968804f0ee2e09e312c75107ee9586a411dfa6c52433304ed11a0c18f55d08e78360d0aaf8815539460b9f603aec57e70dddb5a8af339ad5cfe314fdcd5f2cd11674fc1a34e75 app_engine_release=1.9.71 trace_id=a459042362528c52842c90b6f932f9e0*
  </code></pre>