For a one-shot Node.js task, use the target user’s crontab with an absolute Node binary path, an absolute script path, an explicit working directory, required environment variables, and captured output. Edit it with crontab -e, verify it with crontab -l, and test the exact command as that user. Use node-cron when the schedule belongs inside an always-running Node application, and PM2 when you also need process supervision, crash recovery, and startup after reboot.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
The details that make a schedule dependable are not the five time fields alone. Cron runs with the crontab owner’s identity and a deliberately small shell environment, so an interactive SSH session can succeed while the same command fails in cron. Absolute paths, timezone decisions, logging, idempotency, and overlap protection turn a demonstration into a production job.
As an Amazon Associate I earn from qualifying purchases.
Recommended Free Tools
Choose the scheduler before writing a schedule
There are three distinct designs. Selecting the one that matches the job prevents common problems such as starting multiple copies, losing schedules after a reboot, or putting business logic in the wrong process.
| Scheduler | Best fit | Process behavior | Persistence and controls |
|---|---|---|---|
| System cron | Independent, one-shot commands such as reports, imports, backups, or cleanup | Starts the command at each matching time; no Node process needs to be running beforehand | The per-user crontab remains installed independently of the application process; output, exit status, and daemon logs must be monitored |
| node-cron | Schedule logic that is part of a continuously running Node.js application | The schedule exists only while that Node process is alive | Use the package’s recurring-expression support; process uptime and reboot recovery must be provided by your application supervisor |
| PM2 | Applications that must stay alive, restart after crashes or reboots, and expose operational controls | Supervises a running application and can restart it on a cron pattern with cron_restart |
pm2 startup creates startup integration, and pm2 save stores the process list for restoration |
Use system cron for a one-shot job
System cron is the simplest choice when each run can start, do its work, and exit. Cron examines entries every minute and launches matching commands through the shell configured for that crontab. It does not depend on an application process that was already running, so a failed or stopped web server does not by itself remove the schedule.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Use node-cron for in-process scheduling
node-cron is appropriate when the schedule needs application state, shared database connections, or code paths already living in a long-running service. Its cron-expression syntax is a library feature, not the operating system’s parser; the package supports recurring expressions and an optional seconds field, so check the installed package version and its documentation before relying on a six-field expression. If the process exits, the schedule stops with it.
Use PM2 for supervision and startup recovery
PM2 is a process supervisor rather than a replacement for every cron use case. It can keep a Node application alive, restart it after a crash, restore it after reboot, and expose monitoring controls. Its ecosystem configuration also supports environment variables and a cron_restart pattern. A periodic task inside a PM2-managed application still needs protection against duplicate execution when more than one worker is running.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Prepare a Node.js job that cron can run
Run scheduled work under a dedicated, least-privileged account whenever possible. Give that account ownership of the application files and write access only to the directories and log destinations it needs. Avoid depending on a login shell, an interactive prompt, a home-directory shortcut, or a current working directory inherited from SSH.
Create a stable entry point
Keep the scheduled entry point small. It should load configuration, perform one bounded unit of work, report failures through a non-zero exit status, and terminate. For example, a job might live at /srv/myapp/jobs/backup.js and write its own application errors to standard error. Cron can then redirect both output streams to a known file.
cd /srv/myapp && /usr/bin/node /srv/myapp/jobs/backup.js
Use the real Node binary on your VPS rather than assuming that /usr/bin/node is correct. From the same user who will own the crontab, run:
command -v node
node --version
pwd
command -v node prints the executable path that cron should invoke. If the command returns a path under an NVM directory, record that exact path; cron will not automatically load the interactive shell initialization that normally activates NVM.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Test the job manually as the cron user
Before installing a schedule, execute the complete command as the target account. Include the same working-directory change and environment variables that the cron line will use. Confirm that the process can read its configuration, reach required services, write its output, and exit successfully. A command that works only after an SSH profile is loaded is not ready for cron.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
Install a per-user cron entry safely
The crontab command manages the table for the current user. Each entry runs with that user’s identity. Do not edit files in the cron spool directly; use the command-line editor and let it validate and install the table.
- Resolve the runtime path. As the target user, run
command -v nodeand keep the returned absolute path. - Confirm the application path. Use an absolute path for the script and decide which directory must be current when it runs.
- Open the user’s crontab. Run
crontab -e. The first invocation may ask you to select an editor. - Define a minimal environment. Set
SHELLand a deliberatePATHat the top of the file. Add application variables explicitly rather than assuming an SSH profile will provide them. - Add the schedule. Change the example time and paths to match your job, and redirect standard output and standard error.
- Save and verify. Run
crontab -land check that the installed line is exactly what you intended. - Run the exact command manually. Copy the command portion, including its
cd, and execute it as the same user to catch permissions and environment errors before waiting for the clock.
SHELL=/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin
0 3 * * * cd /srv/myapp && /usr/bin/node /srv/myapp/jobs/backup.js >> /var/log/myapp-backup.log 2>&1
This example starts the script at 03:00 every day in the crontab’s local time. The cd makes the working directory explicit. The absolute Node and script paths remove dependence on PATH lookups. The append operator preserves earlier output, and 2>&1 sends errors to the same log.
Understand the five cron time fields
A standard user crontab line has five time fields followed by the command:
| Field | Allowed values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute within the hour |
| Hour | 0–23 | Hour of the day |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 | Month of the year |
| Day of week | 0–7 | Day name/number according to the cron implementation; 0 and 7 commonly represent Sunday |
Cron checks entries every minute. An asterisk means every permitted value. Lists, ranges, and step values let you express several times without separate entries.
| Expression | Runs |
|---|---|
* * * * * |
Every minute |
0 * * * * |
At minute zero of every hour |
0 3 * * * |
Every day at 03:00 |
15 8 * * 1-5 |
At 08:15 on the selected weekdays |
0 0 1 * * |
At midnight on the first day of each month |
*/10 * * * * |
Every ten minutes |
When both day-of-month and day-of-week are restricted, cron treats either field as a match. That behavior can be surprising: a line that names a particular calendar day and a weekday may run on every matching weekday as well as on the named day. If you need an intersection, put the logic in the command or use separate, clearly documented entries.
Make the cron environment explicit
PATH and shell
SSH starts an interactive shell that may load profile files, aliases, language managers, and custom variables. Cron launches the command through the configured shell with a much smaller environment. Set a known PATH, select the required SHELL, and invoke executables by absolute path where reliability matters.
NVM-managed Node installations
NVM is commonly initialized by shell startup code, which cron does not automatically read. Resolve the actual Node path with command -v node and place that path in the cron command. An alternative is to source a carefully controlled environment file, but it must be tested because sourcing a full interactive profile can introduce output, prompts, or path changes that are unsuitable for cron.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
Working directory and relative paths
Cron does not promise the directory you see after logging in. Relative paths for configuration, uploads, or generated files can therefore point somewhere unexpected. Prefix the command with cd /absolute/application/path &&, or change the application to resolve paths from a known location.
Application variables and secrets
Declare required variables explicitly in the crontab or in a protected environment file. Keep secrets readable only by the account that needs them, and do not print them in diagnostic output. Verify that the cron user can read the file and that the Node process receives the same values as the manual test.
Capture output and determine whether a run succeeded
Without redirection, cron may mail command output to the job owner, and the daemon may also send output to the system log depending on its configuration. For predictable operations, redirect both streams to a log file and inspect the exit status produced by the Node process.
0 * * * * cd /srv/myapp && /usr/bin/node /srv/myapp/jobs/hourly.js >> /var/log/myapp-hourly.log 2>&1
Use MAILTO when local mail delivery is configured and you want cron to notify an address about output:
[email protected]
Choose a log location the cron user can write. If the directory is restricted, create it with the correct ownership before installing the job. Keep enough history to diagnose failures, and arrange a separate rotation policy so an unattended job cannot fill the disk. A silent log is not proof of success: check timestamps, application-level completion records, and the process exit status.
Prevent duplicate or overlapping executions
Cron starts a new invocation when the schedule matches; it does not know whether the previous invocation is still running. A slow import scheduled every five minutes can therefore overlap with itself. Duplicate work can also occur around a daylight-saving transition or after an operator retries a failed run.
- Design the operation to be idempotent: repeating the same input produces the same final state rather than duplicate records or charges.
- Use an application lock or a lockfile strategy when only one instance may run. Remove or expire stale locks safely so a crashed process does not block all future runs.
- Bound the work or split it into resumable batches so one invocation does not occupy the entire interval.
- Record a run identifier, start time, completion time, and outcome so operators can distinguish a skipped run from a failed one.
For a PM2 application, singleton schedules require additional care because each cluster worker can execute the same in-process callback. Keep the schedule in one process or gate it by instance identity, and verify the behavior with the PM2 version and ecosystem configuration deployed on the VPS.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Choose and document the timezone
The five fields are interpreted in the cron daemon’s local timezone unless your platform provides another configuration. Document the timezone next to the crontab entry and decide whether the business rule is truly wall-clock based or should follow UTC.
Daylight-saving transitions can skip a nonexistent local time or run a repeated local time twice. A job scheduled at a transition hour may therefore execute zero times or two times. Make the operation idempotent, monitor the actual run record, and choose a timezone whose behavior matches the business requirement instead of assuming that “03:00” is unambiguous year-round.
Keep a schedule alive after reboot
System cron for independent work
A user crontab is separate from the Node process that performs the task. If the cron service starts normally after reboot, it continues to evaluate the installed table even when no application process was previously running. This is why system cron is often the most direct solution for backups, reports, and maintenance commands.
PM2 startup and saved processes
For an application that must remain online, run the PM2 startup procedure documented for the VPS, then save the process list. The essential sequence is:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall- Start the application under PM2 and confirm it is healthy.
- Run
pm2 startupand follow the command it prints for the server’s init system. - Run
pm2 saveso the current process list is restored after reboot. - Reboot or use the platform’s service checks to verify that the application returns automatically.
If Node is managed by NVM and you change the active Node version, refresh the PM2 startup command as documented. The startup integration may contain the old executable path; updating NVM alone does not guarantee that boot-time PM2 will use the new version.
Schedule inside a Node application with node-cron
Install the node-cron package in the application that will remain running, then register the schedule during startup. A simple hourly callback has the following shape:
const cron = require('node-cron');
cron.schedule('0 * * * *', async () => {
try {
await runHourlyTask();
console.log('Hourly task completed');
} catch (error) {
console.error('Hourly task failed', error);
process.exitCode = 1;
}
});
The process must stay alive for the callback to fire. Run it under a supervisor when it is a service, and ensure only one intended instance owns the schedule. Before deploying, confirm whether your installed node-cron version accepts a seconds field and how it handles missed ticks; do not assume those details from a five-field system-cron example.
Best Value
Use PM2 when uptime and restarts are part of the requirement
PM2 is useful when the scheduled behavior belongs to a persistent application rather than an isolated command. Its ecosystem file can hold environment variables and a cron_restart pattern for restarting a running process on a schedule. Distinguish a restart schedule from a job schedule: restarting a web process every hour is not the same as running a bounded backup function once per hour.
After changing an ecosystem file, reload the application and save the updated process list. In a multi-process or cluster deployment, verify whether each worker receives the schedule. If every worker runs the same callback, add an instance gate or move the singleton task to a separate, single-process entry point.
Troubleshoot the common failure modes
It works in SSH but not in crontab
- Compare
command -v nodein SSH with the absolute binary used by cron. - Check the cron user’s
PATH, shell, working directory, and file permissions. - Confirm every required environment variable is present without relying on profile files.
- Run the exact command as the crontab owner, including its
cdand redirections. - Read both the application log and the cron daemon’s system log when available.
There is no output
Add explicit stdout and stderr redirection, then inspect the log file’s ownership and timestamp. If local mail delivery is available, set MAILTO and check the owner’s mailbox. A command that produces no output may still be succeeding, so include an explicit completion message or durable run record.
The job runs at an unexpected time
Re-read the five fields from left to right, confirm the server’s local timezone, and inspect day-of-month/day-of-week combinations. Around daylight-saving changes, check whether the local time was skipped or repeated and make the operation safe to replay.
The job runs twice
Look for duplicate crontab entries, multiple PM2 workers, and clock-transition behavior. Remove duplicate schedules, keep singleton callbacks in one process, and add an application lock or idempotency key before rerunning the task.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →The schedule disappears or stops after reboot
Confirm the entry with crontab -l under the intended user. If the work is an application process, complete PM2 startup setup and save the process list. If the job is independent, keep it in system cron rather than tying it to an application process that may not be restored.
Production checklist
- Choose system cron, node-cron, or PM2 based on whether the work is independent, in-process, or continuously supervised.
- Use a dedicated user and absolute paths for Node, the script, configuration, and logs.
- Set
SHELL,PATH, working directory, and application variables explicitly. - Test the complete command as the crontab owner before waiting for the schedule.
- Install with
crontab -e; verify withcrontab -l; never edit the spool file directly. - Redirect standard output and standard error, and make failures observable through logs, mail, or both.
- Document the timezone and account for daylight-saving skips and repeats.
- Make the operation idempotent and prevent overlap with a lock or equivalent application control.
- For PM2, run startup setup, save the process list, and refresh startup integration after an NVM-managed Node version change.
- Check real run timestamps and outcomes after deployment rather than treating an installed line as proof that the task executed.
The practical decision
Install a five-field user crontab when the requirement is “start this Node script at these times.” Put the schedule in node-cron when it is inseparable from a living application and that application is already supervised. Choose PM2 when uptime, crash recovery, reboot restoration, environment management, or controlled restarts are first-class requirements. Whichever design you select, explicit paths and environment, observable logs, deliberate timezone handling, and duplicate-run protection determine whether the schedule remains reliable on a real Linux VPS.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




