Skip to content

Guides · VPS

Keep a program running

One systemd service keeps it running, even after reboots.

1. Apps selected with your order

/root/apps has a start.sh in each app directory (Desktop folder on desktop editions).

AppDirectoryStartup unit
Minecraft server (Paper)minecraftminecraft
Web server (Caddy)webweb (started during installation)
Discord bot (Python)discord-botdiscord-bot
Node.js appnode-appnode-app
ActionCommand (in that directory)
Run in the current session./start.sh
Enable at boot + start now./start.sh --service
Disable automatic startup./start.sh --remove-service

2. Run your program as a service

Example: /root/mybot/main.py. nano /etc/systemd/system/mybot.service:

[Unit]
Description=My bot
After=network-online.target
Wants=network-online.target

[Service]
WorkingDirectory=/root/mybot
ExecStart=/root/mybot/venv/bin/python main.py
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
ActionCommand
Enable · startsystemctl daemon-reload && systemctl enable --now mybot
Statussystemctl status mybot
Logs (live)journalctl -u mybot -f
Restart (after editing code)systemctl restart mybot
Stop · disable at bootsystemctl disable --now mybot

Restart=always = restart 5 seconds after exit. After editing the service file, run daemon-reload first.

3. Python venv

apt install -y python3-venv
cd /root/mybot
python3 -m venv venv
venv/bin/pip install -r requirements.txt

Ubuntu 24.04 and Debian 12 or newer restrict system pip installs; use a venv.

4. Node.js

  • Node path: which node → use that path in ExecStart (e.g. ExecStart=/usr/bin/node index.js).
  • Values such as tokens: under [Service], add EnvironmentFile=/root/mybot/.env.

5. Temporary sessions (tmux)

  1. apt install -y tmux → tmux new -s work → run your program.
  2. Press Ctrl+B then D → it keeps running after you close the window.
  3. Reattach: tmux attach -t work.

tmux and screen sessions do not survive a server reboot. Use systemd for persistent programs.

All guides VPS plans Contact support