Jump to content

Recommended Posts

Posted

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?

Posted

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.

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...