Phil Miller
Sep 12, 2017 · 2 min read

As per this comment, it seems this is no longer possible. I’ll leave the post below for posterity’s sake.


Recently, I needed a simple way to send emails at regular times throughout the day. While the cron part of this was well documented, I felt the deployment part could use a simple, fresh approach that didn’t involve Heroku or AWS. I was instantly impressed with now, both in its simplicity and how well thought out everything was.


Assumptions:

You have node installed and understand the basics of the command line.


install express and cron:

npm i express cron --save

create index.js:

install now cli:

(update 2018–12–13: this is based on the older v1.x release of now)

npm i -g now

You can deploy your app by typing now and following the instructions. More detailed docs are here.

Here’s the crucial part to make this work as a cron server. Since the default behavior is to autoscale from 0 to 1 instance (sleeping during periods of inactivity), we need to force it to always have one instance awake via the following command:

now scale https://my-app-replacethis.now.sh 1

That’s it! If you visit https://my-app-replacethis.now.sh/_logs (replaced with your url of course) you should see real-time logs of your cron runs.


One last thing:

Since we’re forcing it to keep each instance alive you need to manually delete old instances after new deploys using the now rm command. You can see a list of all instances using now ls .


I hope this was helpful, please comment if there are any errors or omissions :)

Phil Miller

Written by

I build teams and software. http://themillman.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade