iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
To keep an app running after you close SSH, run it under one process supervisor, configure automatic restarts, register that supervisor at boot, save the process definition, and monitor both logs and application health. For a host-run Node.js or script workload, PM2 provides this workflow. For a containerized workload, Docker’s restart policy should own recovery. “Forever” means automatic recovery from ordinary process crashes and VPS reboots—not immunity from provider outages, broken dependencies, exhausted resources, or bugs in the application.
What “running forever” actually requires
An SSH shell is only an interactive session. When you disconnect, any process tied to that session can receive a hangup signal or simply stop being managed. Tools such as nohup and shell backgrounding may detach a process, but they do not provide a durable definition of the service, a boot-time startup hook, crash recovery, health reporting, or controlled shutdown.
Reliable VPS operation has five separate parts:
- Supervision: a service manager owns the application process and starts it again when it exits unexpectedly.
- Boot persistence: the supervisor itself starts when the VPS boots.
- Saved configuration: the command, working directory, environment, and restart policy are stored somewhere reproducible rather than remembered in a shell history.
- Operational visibility: logs, status output, and a health check show whether users can actually use the service.
- Safe lifecycle handling: the app drains work and closes connections when it receives a termination signal.
A supervisor can restart a process that crashed. It cannot repair a bad release, restore a deleted database, make an unavailable payment provider respond, or compensate for a VPS that is powered off. Treat automatic restart as one layer of availability, not as a complete uptime guarantee.
Choose one restart authority
Decide first whether the app runs directly on the VPS or inside a container. Then assign exactly one component to start, stop, and restart that app. Two independent supervisors create races: one may restart a process while the other is stopping it, hide the real exit status, or produce a rapid restart loop.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
| Option | Best fit | Recovery and boot behavior | Observability | Main caution |
|---|---|---|---|---|
| PM2 on the host | Node.js, Python, shell, Ruby, PHP, or binary applications managed directly on the VPS | Automatic restarts, a generated startup hook, and a saved process list restored after reboot | pm2 status, pm2 logs, pm2 monit, and optional dashboard features |
Use sensible delays or backoff and implement graceful shutdown so dependency failures and deploys do not cause destructive loops |
| Docker restart policy | Applications already packaged as containers | Docker restarts containers according to their policy and starts them when the Docker service starts | Container logs plus an application-level health check | Do not add a host-level process manager to restart the same container |
| systemd or Supervisor | Host-managed services where operating-system-native supervision is preferred | The selected service manager owns the unit and its boot target | Depends on the manager and the VPS logging configuration | Document ownership clearly and do not layer it over another supervisor for the same process |
Prepare the VPS before enabling recovery
Automatic restarts are only useful when the supervisor can reproduce a valid start. Record these details before creating the service:
- The exact executable and arguments, including the application’s entry file.
- The absolute working directory and the Unix user that should own the process.
- Required environment variables, configuration files, ports, and bind addresses.
- Database, queue, cache, and third-party services that must be reachable at startup.
- Where standard output, error output, and structured application logs will be retained.
- How a deployment stops the old version and whether in-flight requests need draining.
Run the app manually once as the intended service user. Confirm that it binds to the expected interface, can read its configuration, reaches required dependencies, and exits with a useful error when initialization fails. A supervisor should not be used to conceal a start command that has never worked interactively.
Configure PM2 for a host-run application
1. Start the app with a stable identity
Install PM2 for the account that will own the application, then start the entry point with a name that will remain stable across deployments:
pm2 start app.js --name my-app
Use the equivalent command for another runtime or executable, supplying its arguments explicitly. The name matters because later status, log, reload, and stop commands should target the intended service rather than an ambiguous process number.
Immediately inspect the result:
pm2 status
The process should be online, with a sensible restart count and the expected working directory. If it exits repeatedly, stop and fix the underlying configuration before proceeding.
2. Generate the boot-time startup hook
Run:
pm2 startup
PM2 detects the available init system and prints a command tailored to that VPS. Copy and execute the generated command with the privileges it requests. This registers PM2 itself to start during a machine boot; it does not by itself know which application processes to restore.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
3. Save the managed process list
After the correct processes are online, run:
pm2 save
PM2 stores the current process definition. On a later reboot, the startup hook launches PM2 and PM2 restores the saved list. Every time you add, remove, rename, or materially reconfigure an app, verify the new state and run pm2 save again. Otherwise the VPS may come back with an older definition.
4. Watch status and logs
Use the built-in views during normal operation and after a restart:
pm2 statusorpm2 listshows process state, restart counts, and basic resource information.pm2 logs my-appfollows standard output and error output for the named process.pm2 monitprovides a live view of CPU, memory, and process activity.
Retain logs outside the terminal session and rotate them before they consume the VPS disk. PM2’s documented log-rotation module can automate rotation; your application should also emit timestamps and request or job identifiers so a failure can be traced across services.
5. Set restart behavior deliberately
A process that fails because a database is unavailable may fail again immediately. A tight loop wastes CPU, floods logs, and can trigger rate limits. PM2 supports a fixed restart delay and exponential backoff. Backoff increases the interval between successive failures and resets after the process has remained stable. Use it when an external dependency may be temporarily unavailable, and pair it with an alert so a slowly restarting but still broken service is not mistaken for a healthy one.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Configure Docker as the container’s restart authority
1. Put the complete runtime in the image
The image should contain the application, its runtime, and its startup command. Configuration that changes by environment belongs in environment variables or mounted configuration, not in an interactive shell command that will disappear when the container is recreated.
2. Select a restart policy
Set a Docker restart policy when you create or define the container. A common production choice is:
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
docker run --restart unless-stopped ...
Other policies are appropriate for different semantics: on-failure limits automatic restarts to non-zero exits, while always requests restarts whenever the container stops. Choose based on whether an intentional stop should remain stopped and whether every exit, including a clean one, should trigger a restart. Keep the policy in your Compose file or deployment definition so it is reproducible.
Do not run PM2, systemd, Supervisor, or a shell watchdog to restart that same container. Docker explicitly warns that combining container restart policies with host-level process managers creates conflicts. A host service may still be responsible for starting the Docker daemon; it should not independently manage the application process inside the container.
Recommended Free Tools
3. Confirm Docker starts at boot
The restart policy is effective only when the Docker service itself starts after a VPS reboot. Enable Docker through the VPS distribution’s normal service-management mechanism, then verify that the container is configured with the intended policy. After a controlled reboot, inspect:
docker ps
and follow output with:
docker logs -f <container-name>
Use the actual container name or ID in place of the example token.
4. Add an application health check
A container can remain running while the application inside is deadlocked, unable to reach its database, or returning errors. Define a health check that exercises a lightweight endpoint and, where appropriate, verifies the dependencies that matter to users. A health check should be fast, deterministic, authenticated when necessary, and cheap enough to run repeatedly. Container status and health status answer different questions: one describes the process lifecycle, the other describes service readiness.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows 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 reinstallWhen systemd or Supervisor is the better fit
Use an operating-system-native manager when the service is a traditional host daemon, when your team already operates units through systemd or Supervisor, or when you need tight integration with host permissions and logging. The important design is the same: define an explicit command, working directory, user, environment, dependency ordering, restart policy, and boot target.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Keep the unit definition in version control and deploy it alongside the application. Reload the manager after changing the definition, start the service, inspect its status and logs, then test a deliberate restart and a reboot. Do not place a PM2-managed process or Docker container inside a second unit that also attempts to restart the underlying workload; choose one owner and let the other layer manage only its own boundary.
Prevent crash loops and dependency storms
Automatic recovery can amplify an outage if every failed start happens immediately. A practical policy has three elements:
- Delay: wait a fixed interval before retrying short-lived failures.
- Backoff: increase the delay after repeated failures, especially when a database, API, DNS service, or queue is unavailable.
- Visibility: alert on repeated exits, rising restart counts, and prolonged unhealthiness.
Backoff is not a substitute for fixing the dependency. Check credentials, DNS, firewall rules, migrations, connection limits, and provider status. Once the dependency returns, the app should recover without manual shell intervention. A stable run should reset exponential backoff so a later, unrelated crash is not delayed by an old incident.
Implement graceful shutdown before production restarts
Deployments, VPS maintenance, and supervisor restarts send termination signals. If the app exits immediately, requests in progress can be truncated and queued work can be lost. Handle SIGINT and SIGTERM explicitly.
A graceful shutdown follows five practical stages:
- Notify the application that termination has begun.
- Stop accepting new HTTP requests or jobs.
- Allow in-flight requests and active jobs to finish within a defined deadline.
- Release database, queue, cache, file, and network connections.
- Exit with an appropriate status so the supervisor knows whether the stop was intentional or a failure.
Test this path independently of a crash test. A restart that appears successful from the outside can still drop requests if the old process is killed before it drains.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Monitor health, not just process existence
Design a useful health endpoint
Expose a lightweight endpoint such as /health or /ready. Decide what it means before implementing it. A liveness check may answer only whether the process can respond. A readiness check should also verify critical dependencies, such as a database connection or queue, and return an unhealthy result when the app cannot serve real traffic.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Do not make the check depend on a slow, expensive report or an operation that mutates data. Separate liveness from readiness when your deployment system supports both, and avoid exposing sensitive diagnostic details in a public response.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Make logs actionable
Capture startup failures, dependency errors, shutdown progress, restart reasons, and health-check failures. Include timestamps, severity, and a request or job identifier. Stream container logs or PM2 output to a retained destination, and rotate files before disk exhaustion. A full disk can prevent both the app and its supervisor from writing state, turning a recoverable error into a longer outage.
Watch resource limits
Track memory, CPU, disk space, open files, and network capacity. A process killed by the kernel for exhausting memory may look like an ordinary crash unless you inspect host events and supervisor logs. Set realistic container or service limits, then tune the application so normal load does not sit at the limit.
Verify recovery instead of assuming it
Run these checks during a maintenance window and record the expected result:
- Restart the supervisor or container and confirm the app returns without manual shell commands.
- Reboot the VPS and verify that the supervisor, app, listener, and health endpoint all return.
- Simulate an application failure by stopping or terminating the app process, not by deleting data.
- Confirm that the supervisor records the failure and starts a new process or container.
- Request the health endpoint and a representative user operation.
- Review logs for startup order, dependency errors, graceful shutdown, and the recovery event.
- Check that restart counts do not continue climbing after recovery.
This exercise is an operator procedure, not a guarantee that every provider or network failure will be recovered automatically. Repeat it after changing the startup command, process user, image, environment, or boot configuration.
Free tools Windows power users keep installed
One-click scans. No signup required.
Troubleshoot common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| The app stops when SSH closes | It was launched in the shell without durable supervision | Move it under PM2, Docker, systemd, or Supervisor; verify the supervisor owns the process |
| The app works until a VPS reboot | The supervisor startup hook or saved definition is missing | For PM2, run pm2 startup using its generated command and then pm2 save; for Docker, verify the daemon starts and the container has a restart policy |
| The supervisor reports online but users receive errors | The process exists but initialization, dependencies, or request handling is unhealthy | Read application logs, call the health endpoint, and test database, queue, DNS, and upstream connectivity |
| CPU and logs spike after a dependency outage | Immediate restart attempts create a crash loop | Configure a fixed delay or exponential backoff, then fix the failing dependency and alert on repeated exits |
| Deployments drop requests | The process exits before draining in-flight work | Implement SIGTERM/SIGINT handling, stop new work, finish active requests, close resources, and enforce a deadline |
| A container and host service keep restarting each other | Two restart authorities manage one workload | Remove the competing manager and leave Docker’s restart policy as the container authority |
| Recovery fails with “no space left” errors | Unrotated logs or application data filled the disk | Inspect disk usage, rotate or retain logs safely, free space, and add disk alerts before restarting |
Operational practices that make restarts safe
- Run the service as a dedicated, least-privileged user rather than root whenever the application permits.
- Keep secrets in the VPS secret mechanism or protected environment configuration; do not print them in startup logs.
- Pin runtime and dependency versions so a reboot does not silently select a different environment.
- Back up application data and configuration separately from the VPS process definition. A supervisor can recreate a process, not lost data.
- Document the owner, startup command, restart policy, health URL, log location, and rollback procedure.
- Use a maintenance window for reboot and failure-injection tests, and retain the observed results for the next operator.
Bottom line
For a directly hosted app, PM2’s durable pattern is pm2 start, the generated pm2 startup command, and pm2 save, followed by continuous use of status, logs, and monitoring. For a container, define Docker’s restart policy and let Docker remain the sole restart authority. Whichever model you choose, add backoff, graceful shutdown, health checks, log rotation, and deliberate reboot and crash tests. That combination is what makes a VPS app resilient after SSH disconnects, ordinary crashes, and host reboots.
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.

