Ketan Mistry
Ketan Mistry

Reputation: 45

How to create a cron job on a Google Compute Engine instance via a PHP App Engine application?

Due to the architecture of our App Engine application we can't use the App Engine cron service that Google provides and are looking for alternative options.

One possible solution we have come up with is to allow our App Engine PHP application to automatically create a cronjob on a compute engine instance. This instance would simply be a utility machine which would handle nothing but the cron jobs.

How would we create the crons in compute engine from within the App Engine application using PHP?

Upvotes: 4

Views: 7152

Answers (2)

Nathan majicvr.com
Nathan majicvr.com

Reputation: 1041

I don't use PHP, but it may help the reader to know you can just do

sudo crontab -e

on an Ubuntu 16 GCloud Compute Engine instance like on a normal Linux box

Upvotes: 0

Blue
Blue

Reputation: 22921

Because your google cloud instances can go down or up at any minute, (And also, you may have multiple instances of the same app running), which would make cron unreliable as it may trigger multiple times across multiple machines, google has created Task Scheduling, which is available on Google Compute Engine.

A great tutorial can be found here, and a sample can be found here.

For a PHP specific implementation of pub/sub, see this link.

Upvotes: 2

Related Questions