hosting for node.js is still not very widespread, especially in the german-speaking world. here, the american cloud company heroku offers a remedy - and even for free. you always notice the paradigm "build apps... not infrastructure" and yet you have hardly any restrictions. we implement a small cronjob based on phantomJS as an example, which scans a website every day and sends the page title via email.
To do this, we first register free of charge at https://signup.heroku.com/:
After the obligatory e-mail confirmation, we will issue a secure password:
In order to be able to use free add-ons from the Marketplace later, we first have to verify our account under https://heroku.com/verify by entering a credit card (don't worry, everything remains free):
We finally log in (once) locally to Heroku on the command line:
The actual logic can be found in script.js:
We first test everything locally:
The script extracts a title from a website and sends an email:
We now push everything on Heroku that triggers the build process:
If you want to push code changes to Heroku later on, you just push again and we can now check via SSH if everything is running on the server:
Here, too, the email is sent correctly. Now we just have to automate the process:
We add a new script call with "Add new job:
As frequency we select every 10 minutes as a test and save:
The cronjob will now automatically do its job.