{"id":21119,"date":"2026-10-21T02:53:46","date_gmt":"2026-10-21T02:53:46","guid":{"rendered":"https:\/\/www.hostinger.com\/support\/?p=21119"},"modified":"2026-10-21T03:35:29","modified_gmt":"2026-10-21T03:35:29","slug":"how-to-run-cron-jobs-for-node-js-websites-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/how-to-run-cron-jobs-for-node-js-websites-at-hostinger\/","title":{"rendered":"How to run cron jobs for Node.js websites at Hostinger"},"content":{"rendered":"<p>Node.js cron jobs at Hostinger run a script from your Node.js website on a schedule, for example to send reports, clean up data or sync records. The Cron Jobs tool has supported Node.js websites since 8 October 2026 and pre-fills the Node.js part of the command. To set one up, open Cron Jobs, enter the command with your script path, and set the schedule. Node.js cron jobs run in UTC, stop after 30 minutes, and don&rsquo;t receive your website&rsquo;s environment variables unless you load them in the command.<\/p><h3><b>Before you start<\/b><\/h3><ul>\n<li>You need a Node.js website on a web or cloud hosting plan that supports Node.js. Check the Node.js website limits in <a data-click-id=\"hgr-post-content-link-parameters-and-limits-of-hosting-plans-in-hostinger\" href=\"https:\/\/www.hostinger.com\/support\/6976044-parameters-and-limits-of-hosting-plans-in-hostinger\/\">parameters and limits of hosting plans in Hostinger<\/a>.<\/li>\n<li><a data-click-id=\"hgr-post-content-link-redeploy-your-node-js-website\" href=\"https:\/\/www.hostinger.com\/support\/how-to-redeploy-a-node-js-application\/\">Redeploy your Node.js website<\/a> first if it hasn&rsquo;t been redeployed since August 2026. Older deployments use a different folder structure, so the paths in this article won&rsquo;t match.<\/li>\n<li>Test your script before scheduling it.<\/li>\n<\/ul><h2 id=\"h-set-up-a-node-js-cron-job\">Set up a Node.js cron job<\/h2><h3>Step 1 &ndash; Open Cron Jobs<\/h3><p>Open the dashboard of your Node.js website and go to <b>Advanced<\/b> &rarr; <b>Cron Jobs<\/b>. The Node.js command is pre-filled in the command field. For general cron job settings, see <a data-click-id=\"hgr-post-content-link-how-to-set-up-a-cron-job-at-hostinger\" href=\"https:\/\/www.hostinger.com\/support\/1583465-how-to-set-up-a-cron-job-at-hostinger\/\">how to set up a cron job at Hostinger<\/a>.<\/p><h3>Step 2 &ndash; Enter the Node.js command<\/h3><p>A Node.js cron job command has three parts:<\/p><ul>\n<li><b>Node.js path<\/b>: <code>\/opt\/alt\/alt-nodejs20\/root\/bin\/node<\/code>. Replace <code>20<\/code> with the Node.js version of your website: <code>18<\/code>, <code>20<\/code>, <code>22<\/code> or <code>24<\/code>. See <a data-click-id=\"hgr-post-content-link-how-to-select-the-node-js-version-for-your-application\" href=\"https:\/\/www.hostinger.com\/support\/how-to-select-the-node-js-version-for-your-application\/\">how to select the Node.js version for your application<\/a>.<\/li>\n<li><b>Environment variables (optional)<\/b>: <code>--env-file=\/home\/u123456789\/domains\/domain.tld\/hbuilds\/config\/.env<\/code>. Add this only if your script uses environment variables.<\/li>\n<li><b>Script path<\/b>: the full path to your script inside the deployed website, for example <code>\/home\/u123456789\/domains\/domain.tld\/hbuilds\/current\/nodejs\/scripts\/job.js<\/code>.<\/li>\n<\/ul><p>A complete command looks like this:<\/p><pre><code>\/opt\/alt\/alt-nodejs20\/root\/bin\/node --env-file=\/home\/u123456789\/domains\/domain.tld\/hbuilds\/config\/.env \/home\/u123456789\/domains\/domain.tld\/hbuilds\/current\/nodejs\/scripts\/job.js<\/code><\/pre><p>Replace <code>u123456789<\/code> with your username and <code>domain.tld<\/code> with your domain.<\/p><h3>Step 3 &ndash; Set the schedule and save<\/h3><p>Choose a common schedule or set one manually, then click <b>Save<\/b>. The cron job runs on the schedule you set, based on Coordinated Universal Time (UTC).<\/p><p><img decoding=\"async\" class=\"alignnone size-full wp-image-21120\" src=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\" alt=\"\" width=\"1612\" height=\"577\" srcset=\"https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png 1612w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53-300x107.png 300w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53-1024x367.png 1024w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53-768x275.png 768w, https:\/\/www.hostinger.com\/support\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53-1536x550.png 1536w\" sizes=\"(max-width: 1612px) 100vw, 1612px\" \/><\/p><h2 id=\"h-load-environment-variables-in-a-node-js-cron-job\">Load environment variables in a Node.js cron job<\/h2><p>A Node.js cron job doesn&rsquo;t receive your website&rsquo;s <a data-click-id=\"hgr-post-content-link-environment-variables\" href=\"https:\/\/www.hostinger.com\/support\/how-to-edit-or-add-environment-variables-after-deployment\/\">environment variables<\/a> automatically. Add <code>--env-file=\/home\/u123456789\/domains\/domain.tld\/hbuilds\/config\/.env<\/code> to the command to load them. The <code>--env-file<\/code> option requires Node.js 20.6 or newer, so it doesn&rsquo;t work on Node.js 18.<\/p><h2 id=\"h-node-js-cron-job-limits\">Node.js cron job limits<\/h2><p>Node.js cron jobs at Hostinger follow four rules:<\/p><ul>\n<li>Each cron job runs one command.<\/li>\n<li>The command must be 255 characters or shorter.<\/li>\n<li>The command can&rsquo;t contain the <code>%<\/code> character, because cron treats it as a line break.<\/li>\n<li>A cron job is stopped after 30 minutes.<\/li>\n<\/ul><p>Cron jobs suit tasks that start, finish and exit, for example a nightly cleanup. They don&rsquo;t replace always-running background workers such as queue workers or bots, which aren&rsquo;t supported, as listed in <a data-click-id=\"hgr-post-content-link-hostinger-node-js-hosting-limits-for-web-and-cloud-plans\" href=\"https:\/\/www.hostinger.com\/support\/hostinger-node-js-limits-for-web-and-cloud-plans\/\">Hostinger Node.js hosting limits for web and cloud plans<\/a>. For the number of cron jobs per plan, see <a data-click-id=\"hgr-post-content-link-how-many-cron-jobs-you-can-set-up-in-hostinger\" href=\"https:\/\/www.hostinger.com\/support\/1583765-how-many-cron-jobs-can-you-set-up-in-hostinger\/\">how many cron jobs you can set up in Hostinger<\/a>.<\/p><h2 id=\"h-run-a-node-js-cron-job-through-a-website-url\">Run a Node.js cron job through a website URL<\/h2><p>Call a protected route of your Node.js app with <code>curl<\/code> if you&rsquo;d rather keep the task inside your app. Protect the route with a secret key so only the cron job can trigger it:<\/p><pre><code>curl -s https:\/\/domain.tld\/api\/cron?key=your-secret-key<\/code><\/pre><p>This option uses your app&rsquo;s existing environment variables, so the <code>--env-file<\/code> option isn&rsquo;t needed.<\/p><h2 id=\"h-check-the-output-of-a-node-js-cron-job\">Check the output of a Node.js cron job<\/h2><p>Node.js cron jobs log their output the same way as other cron jobs. Follow <a data-click-id=\"hgr-post-content-link-how-to-check-the-output-of-a-cron-job-at-hostinger\" href=\"https:\/\/www.hostinger.com\/support\/5647075-how-to-check-the-output-of-a-cron-job-at-hostinger\/\">how to check the output of a cron job at Hostinger<\/a> to view the results. If a cron job doesn&rsquo;t run, see <a data-click-id=\"hgr-post-content-link-troubleshooting-cron-jobs-at-hostinger\" href=\"https:\/\/www.hostinger.com\/support\/1583514-troubleshooting-cron-jobs-at-hostinger\/\">troubleshooting cron jobs at Hostinger<\/a>.<\/p><p>Your Node.js cron job now runs on schedule. If it doesn&rsquo;t run as expected, check the cron job output first, then confirm the Node.js version and script path in the command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Schedule Node.js scripts on Hostinger web and cloud hosting using the Cron Jobs tool.<\/p>\n","protected":false},"author":594,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[229],"tags":[],"class_list":["post-21119","post","type-post","status-publish","format-standard","hentry","category-cron-jobs"],"hreflangs":[],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/21119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/594"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=21119"}],"version-history":[{"count":3,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/21119\/revisions"}],"predecessor-version":[{"id":21157,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/21119\/revisions\/21157"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=21119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=21119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=21119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}