Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine for pseudo-cronjobs?

I look for a possibility to create pseudo-cronjobs as I cannot use the real jobs on UNIX.

Since Python scripts can run for an unlimited period, I thought Python would be a great solution.

On Google App Engine you can set up Python scripts and it's free. So I should use the App Engine.

The App Engine allows 160,000 external URL accesses (right?) so you should have 160000/31/24/60 = 3,6 accesses per minute.

So my script would be:

import time
import urllib
while time.clock() < 86400:
    # execute pseudo-cronjob file and then wait 60 seconds
    content = urllib.urlopen('http://www.example.org/cronjob_file.php').read()
    time.sleep(60)

Unfortunately, I have no possibility to test the script, so my questions are: 1) Do you think this would work? 2) Is it allowed (Google TOS) to use the service for such an activity? 3) Is my calculation for the URL accesses per minute right?

Thanks in advance!

like image 519
caw Avatar asked Dec 30 '22 01:12

caw


2 Answers

Maybe I'm misunderstanding you, but the cron config files will let you do this (without Python). You can add something like this to you cron.yaml file:

cron:
- description: job that runs every minute
  url: /cronjobs/job1
  schedule: every minute

See Google's documentation for more info on scheduling.

like image 188
Jason Coon Avatar answered Jan 04 '23 16:01

Jason Coon


Google has some limits on how long a task can run.

URLFetch calls made in the SDK now have a 5 second timeout, here

They allow you to schedule up to 20 cron tasks in any given day. Here

like image 33
user91821 Avatar answered Jan 04 '23 17:01

user91821