For Linux servers, the best way to run Telbot in --bot or --mcp mode continuously is by creating a systemd service. This ensures the bot starts automatically on boot and restarts if it crashes.
Get the latest binary from the releases page.
wget https://github.com/0xtbug/telbot/releases/latest/download/telbot-linux-amd64Move your telbot binary to a global location so the system can access it easily.
sudo mv telbot-linux-amd64 /usr/local/bin/telbot
sudo chmod +x /usr/local/bin/telbotNote: Make sure name of the binary is
telbot.
Create a new file at /etc/systemd/system/telbot.service:
sudo nano /etc/systemd/system/telbot.servicePaste the following configuration (adjust User, WorkingDirectory, and the Environment variables as needed):
[Unit]
Description=Telkomsel Telegram Bot
After=network.target
[Service]
Type=simple
# Change to your Linux username
User=your_username
# Change to the directory where your sessions.json and other files should live
WorkingDirectory=/home/your_username/telkomsel-bot
# Set your environment variables here
Environment="TELKOMSEL_BOT_TOKEN=your_telegram_bot_token"
Environment="TELEGRAM_ADMIN_ID=your_telegram_id"
# Optional: Enable auto re-login via OTP webhook from SMS Forwarder
# Environment="OTP_WEBHOOK_PORT=8081"
# Environment="OTP_WEBHOOK_SECRET=your_secret"
# The command to execute
ExecStart=/usr/local/bin/telbot --bot
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetReload the systemd daemon to recognize your new service:
sudo systemctl daemon-reloadEnable the service to start automatically on boot:
sudo systemctl enable telbotStart the service now:
sudo systemctl start telbotTo view the real-time logs of your bot:
sudo journalctl -u telbot -f