{"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-29T15:20:08","modified_gmt":"2026-10-29T15:20:08","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\u2019t receive your website\u2019s environment variables unless you load them in the command.<\/p>\n<h3><b>Before you start<\/b><\/h3>\n<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=\"\/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=\"\/support\/how-to-redeploy-a-node-js-application\/\">Redeploy your Node.js website<\/a> first if it hasn\u2019t been redeployed since August 2026. Older deployments use a different folder structure, so the paths in this article won\u2019t match.<\/li>\n<li>Test your script before scheduling it.<\/li>\n<\/ul>\n<h2 id=\"h-set-up-a-node-js-cron-job\">Set up a Node.js cron job<\/h2>\n<h3>Step 1 \u2013 Open Cron Jobs<\/h3>\n<p>Open the dashboard of your Node.js website and go to <b>Advanced<\/b> \u2192 <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=\"\/support\/1583465-how-to-set-up-a-cron-job-at-hostinger\/\">how to set up a cron job at Hostinger<\/a>.<\/p>\n<h3>Step 2 \u2013 Enter the Node.js command<\/h3>\n<p>A Node.js cron job command has three parts:<\/p>\n<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=\"\/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>\n<p>A complete command looks like this:<\/p>\n<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>\n<p>Replace <code>u123456789<\/code> with your username and <code>domain.tld<\/code> with your domain.<\/p>\n<h3>Step 3 \u2013 Set the schedule and save<\/h3>\n<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>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-21120\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\/public\" alt=\"\" width=\"1612\" height=\"577\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\/w=1612,fit=scale-down 1612w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/55\/2026\/10\/2026-10-21_09-53.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1612px) 100vw, 1612px\" \/><\/p>\n<h2 id=\"h-load-environment-variables-in-a-node-js-cron-job\">Load environment variables in a Node.js cron job<\/h2>\n<p>A Node.js cron job doesn\u2019t receive your website\u2019s <a data-click-id=\"hgr-post-content-link-environment-variables\" href=\"\/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\u2019t work on Node.js 18.<\/p>\n<h2 id=\"h-node-js-cron-job-limits\">Node.js cron job limits<\/h2>\n<p>Node.js cron jobs at Hostinger follow four rules:<\/p>\n<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\u2019t 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>\n<p>Cron jobs suit tasks that start, finish and exit, for example a nightly cleanup. They don\u2019t replace always-running background workers such as queue workers or bots, which aren\u2019t supported, as listed in <a data-click-id=\"hgr-post-content-link-hostinger-node-js-hosting-limits-for-web-and-cloud-plans\" href=\"\/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=\"\/support\/1583765-how-many-cron-jobs-can-you-set-up-in-hostinger\/\">how many cron jobs you can set up in Hostinger<\/a>.<\/p>\n<h2 id=\"h-run-a-node-js-cron-job-through-a-website-url\">Run a Node.js cron job through a website URL<\/h2>\n<p>Call a protected route of your Node.js app with <code>curl<\/code> if you\u2019d rather keep the task inside your app. Protect the route with a secret key so only the cron job can trigger it:<\/p>\n<pre><code>curl -s https:\/\/domain.tld\/api\/cron?key=your-secret-key<\/code><\/pre>\n<p>This option uses your app\u2019s existing environment variables, so the <code>--env-file<\/code> option isn\u2019t needed.<\/p>\n<h2 id=\"h-check-the-output-of-a-node-js-cron-job\">Check the output of a Node.js cron job<\/h2>\n<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=\"\/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\u2019t run, see <a data-click-id=\"hgr-post-content-link-troubleshooting-cron-jobs-at-hostinger\" href=\"\/support\/1583514-troubleshooting-cron-jobs-at-hostinger\/\">troubleshooting cron jobs at Hostinger<\/a>.<\/p>\n<p>Your Node.js cron job now runs on schedule. If it doesn\u2019t 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":{"_content_updated_date":"","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":4,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/21119\/revisions"}],"predecessor-version":[{"id":23873,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/21119\/revisions\/23873"}],"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}]}}