Webtask.io : Cron job as a Service

Welcome to serverless era! I should say Theres a serverless for that from now on. Lets start with cron job.

Welcome webtask.io!

It will do free 2 cron job for you so lets begin.

Install wt command line interface.

$ npm install wt-cli -g

Initialize wt.

$ wt init YOUR_EMAIL

Youll get

Please enter the verification code we sent to foo@bar.com below.
Verification code: 123456
Welcome to webtasks! Create your first one as follows:
$ echo "module.exports = function (cb) { cb(null, 'Hello'); }" > hello.js
$ wt create hello.js

Create a simple webtask.

$ echo "module.exports = function (cb) {cb(null, 'Hello');}" > hello.js


$ wt create hello.js

Then youll get

Webtask createdYou can access your webtask at the following url:https://wt-foo-bar-com-0.run.webtask.io/hello

Nice! the fun is just start you can check here for modules you can require e.g fetch

Lets try fetch webtasks README.md

Modify hello.js as below.

var fetch = require('isomorphic-fetch@2.2.0')module.exports = function (cb) {
.then(function (response) {
if (response.status >= 400) {
throw new Error("Bad response from server");
return response.text();
}).then(function (text) {
console.log(new Date().toUTCString());
cb(null, text);

And update it

$ wt update hello hello.js

Then try curl it you should get

Now we cron every 2 minutes

$ wt cron schedule "*/2 * * * *" ./hello.js
Name: hello
State: active
Container: wt-katopz-gmail-com-0
Schedule: */2 * * * *
Next run: 1/16/2017, 11:14:00 PM

To ensure everything working, we log!

$ wt logs

And you should see

[16:13:43.288Z]  INFO wt: connected to streaming logs (container=wt-katopz-gmail-com-0)
[16:14:03.055Z] INFO wt: new webtask request 1484583242765.907460
[16:14:03.323Z] INFO wt: Mon, 16 Jan 2017 16:14:03 GMT
[16:14:03.330Z] INFO wt: finished webtask request 1484583242765.907460 with HTTP 200 in 396ms
[16:16:10.455Z] INFO wt: new webtask request 1484583370163.697907
[16:16:10.695Z] INFO wt: Mon, 16 Jan 2017 16:16:10 GMT
[16:16:10.695Z] INFO wt: finished webtask request 1484583370163.697907 with HTTP 200 in 379ms

Every 2 minutes! FYI, for free plan you can create only 2 crons.

Enjoy repeat yourself!

Note (ref)

Dont miss a chance to get free $10 for DigitalOcean 2 months free hosting!
And do claim your cheapest .io name before its gone at NameCheap.

DLT & ML Debugger