mricardi Posted November 6 Posted November 6 Hey guys! I was developing a script in nodejs. It’s a simple one that just gets info from an external API and inserts it into a database. My idea is to run this script once per day. I tried to set up a scheduled task to run "node myscript.js" but I saw that I don't have permissions to run nodejs from a scheduled task. So my question is, is there a way to execute a nodejs script from a scheduled task, or should I look for another way?
wolstech Posted November 6 Posted November 6 Scheduled tasks are jailed to your home folder, so they cannot see the node binaries. The easiest solution is to make a web endpoint that can be called to trigger it (e.g. https://domain.heliohost.us/api/cron), and have the task call it using the fetch URL option to trigger it. Not sure how this would be done in Node specifically, but this is the typical solution used for other languages like PHP. You may need a separate subdomain for it if its a separate application. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now