Cara Menggunakan OpenClaw
untuk Automation Task di VPS Linux

Real-world examples: dari backup otomatis, monitoring, deployment, sampai webhook integration.

± 35 menit baca SufaNet
OpenClaw Automation Task

Pendahuluan

OpenClaw sudah terinstall, AI API sudah terhubung. Sekarang pertanyaannya: mau dipakai buat apa?

Artikel ini akan kasih kamu real-world examples penggunaan OpenClaw untuk automation task di VPS Linux. Bukan teori doang, tapi contoh konkret yang bisa langsung kamu implement hari ini.

Kita akan bahas berbagai use case seperti automated backup, system monitoring, auto deployment, scheduled tasks, webhook integration, dan masih banyak lagi.

💡 Prerequisite: Pastikan OpenClaw sudah running dan AI API sudah dikonfigurasi. Kalau belum, baca artikel sebelumnya tentang instalasi, konfigurasi, dan AI integration.

Konsep Task Automation dengan OpenClaw

OpenClaw bekerja dengan konsep task definition. Sebuah task terdiri dari:

  • Trigger — kapan task dijalankan (schedule, webhook, manual)
  • Condition — syarat yang harus dipenuhi
  • Action — apa yang dilakukan (shell command, API call, script)
  • AI Decision — keputusan cerdas berdasarkan context
  • Notification — alert kalau berhasil/gagal

Format dasar task definition:

{
  "name": "backup-database",
  "trigger": "schedule",
  "schedule": "0 2 * * *",
  "actions": [
    {
      "type": "shell",
      "command": "mysqldump -u root -p$DB_PASS mydb > /backup/db.sql"
    },
    {
      "type": "notification",
      "channel": "telegram",
      "message": "Database backup completed"
    }
  ]
}

Use Case 1: Automated Backup

Backup adalah task paling krusial tapi sering terlupakan. OpenClaw bisa automate ini dengan cerdas.

Backup Database Otomatis

Buat file task definition:

nano ~/openclaw/tasks/backup-database.json
{
  "name": "backup-database-daily",
  "description": "Backup MySQL database setiap hari jam 2 pagi",
  "trigger": "schedule",
  "schedule": "0 2 * * *",
  "enabled": true,
  "actions": [
    {
      "type": "shell",
      "command": "mkdir -p /backup/$(date +%Y%m%d)"
    },
    {
      "type": "shell",
      "command": "mysqldump -u root -p${DB_PASSWORD} ${DB_NAME} | gzip > /backup/$(date +%Y%m%d)/db_$(date +%H%M%S).sql.gz"
    },
    {
      "type": "ai-check",
      "prompt": "Check if backup file size is reasonable (>1MB but <1GB)",
      "onFail": "notify-admin"
    },
    {
      "type": "shell",
      "command": "find /backup/* -mtime +7 -delete",
      "description": "Delete backups older than 7 days"
    }
  ],
  "notifications": {
    "onSuccess": {
      "channel": "telegram",
      "message": "✅ Database backup completed successfully"
    },
    "onError": {
      "channel": "telegram",
      "message": "❌ Database backup failed! Check logs."
    }
  }
}

Task ini akan:

  • Jalan otomatis setiap hari jam 2 pagi
  • Buat backup dengan timestamp
  • AI check apakah file size wajar
  • Auto delete backup yang lebih dari 7 hari
  • Kirim notifikasi Telegram

Backup Files & Directories

{
  "name": "backup-website-files",
  "schedule": "0 3 * * *",
  "actions": [
    {
      "type": "shell",
      "command": "tar -czf /backup/$(date +%Y%m%d)/website.tar.gz /var/www/html"
    },
    {
      "type": "upload",
      "destination": "s3://my-bucket/backups/",
      "file": "/backup/$(date +%Y%m%d)/website.tar.gz"
    }
  ]
}

Use Case 2: System Monitoring

OpenClaw bisa monitor kesehatan server dan alert kalau ada masalah.

Monitor Disk Usage

{
  "name": "monitor-disk-usage",
  "trigger": "schedule",
  "schedule": "*/30 * * * *",
  "actions": [
    {
      "type": "shell",
      "command": "df -h / | tail -1 | awk '{print $5}' | sed 's/%//'",
      "output": "disk_usage"
    },
    {
      "type": "condition",
      "if": "disk_usage > 80",
      "then": [
        {
          "type": "ai-analyze",
          "prompt": "Analyze which directory is using most space and suggest cleanup actions",
          "input": "$(du -sh /* | sort -rh | head -10)"
        },
        {
          "type": "notification",
          "channel": "telegram",
          "message": "⚠️ Disk usage is {{disk_usage}}%! AI Recommendation: {{ai_response}}"
        }
      ]
    }
  ]
}

Monitor CPU & Memory

{
  "name": "monitor-resources",
  "schedule": "*/15 * * * *",
  "actions": [
    {
      "type": "shell",
      "command": "top -bn1 | grep 'Cpu(s)' | awk '{print $2}' | sed 's/%us,//'",
      "output": "cpu_usage"
    },
    {
      "type": "shell",
      "command": "free | grep Mem | awk '{print ($3/$2) * 100.0}'",
      "output": "memory_usage"
    },
    {
      "type": "ai-decision",
      "prompt": "CPU: {{cpu_usage}}%, Memory: {{memory_usage}}%. Should I take action?",
      "actions": {
        "restart_service": "systemctl restart heavy-app",
        "scale_up": "notify-admin-to-upgrade",
        "no_action": "continue"
      }
    }
  ]
}

Monitor Website Uptime

{
  "name": "check-website-uptime",
  "schedule": "*/5 * * * *",
  "actions": [
    {
      "type": "http",
      "method": "GET",
      "url": "https://yourdomain.com",
      "timeout": 10000,
      "output": "response"
    },
    {
      "type": "condition",
      "if": "response.status != 200",
      "then": [
        {
          "type": "notification",
          "channel": "telegram",
          "message": "🚨 Website DOWN! Status: {{response.status}}"
        },
        {
          "type": "ai-troubleshoot",
          "prompt": "Website returning {{response.status}}. Check logs and suggest fix",
          "context": "$(tail -50 /var/log/nginx/error.log)"
        }
      ]
    }
  ]
}

Use Case 3: Automated Deployment

Auto deploy aplikasi dari Git repository dengan zero-downtime.

Git Auto-Deploy

{
  "name": "auto-deploy-from-git",
  "trigger": "webhook",
  "webhook_path": "/deploy/production",
  "actions": [
    {
      "type": "shell",
      "command": "cd /var/www/myapp && git pull origin main"
    },
    {
      "type": "ai-check",
      "prompt": "Review git changes and detect if breaking changes exist",
      "input": "$(git log -1 --pretty=%B)"
    },
    {
      "type": "shell",
      "command": "npm install --production"
    },
    {
      "type": "shell",
      "command": "npm run build"
    },
    {
      "type": "shell",
      "command": "pm2 reload myapp"
    },
    {
      "type": "notification",
      "channel": "slack",
      "message": "✅ Deployed to production: {{git_commit_message}}"
    }
  ],
  "rollback_on_error": true
}

Docker Auto-Rebuild

{
  "name": "rebuild-docker-container",
  "trigger": "webhook",
  "actions": [
    {
      "type": "shell",
      "command": "docker compose pull"
    },
    {
      "type": "shell",
      "command": "docker compose up -d --build"
    },
    {
      "type": "wait",
      "duration": 10000,
      "description": "Wait for container to start"
    },
    {
      "type": "health-check",
      "url": "http://localhost:3000/health"
    }
  ]
}

Use Case 4: Scheduled Tasks

Task yang jalan pada waktu tertentu atau interval berkala.

Database Cleanup

{
  "name": "cleanup-old-data",
  "schedule": "0 4 * * SUN",
  "description": "Clean up old data every Sunday at 4 AM",
  "actions": [
    {
      "type": "ai-query",
      "prompt": "Generate safe SQL query to delete records older than 90 days from logs table",
      "validate": true
    },
    {
      "type": "shell",
      "command": "mysql -u root -p${DB_PASS} -e '{{ai_generated_query}}'"
    },
    {
      "type": "shell",
      "command": "mysqlcheck -u root -p${DB_PASS} --optimize --all-databases"
    }
  ]
}

SSL Certificate Renewal

{
  "name": "renew-ssl-certificate",
  "schedule": "0 3 1 * *",
  "description": "Check and renew SSL cert every month",
  "actions": [
    {
      "type": "shell",
      "command": "certbot renew --quiet"
    },
    {
      "type": "condition",
      "if": "exit_code == 0",
      "then": [
        {
          "type": "shell",
          "command": "systemctl reload nginx"
        },
        {
          "type": "notification",
          "message": "SSL certificate renewed successfully"
        }
      ]
    }
  ]
}

Use Case 5: Webhook Integration

OpenClaw bisa menerima webhook dari service eksternal dan trigger action.

GitHub Webhook

{
  "name": "github-push-handler",
  "trigger": "webhook",
  "webhook_path": "/webhooks/github",
  "webhook_secret": "${GITHUB_WEBHOOK_SECRET}",
  "actions": [
    {
      "type": "ai-parse",
      "prompt": "Extract repository name, branch, and commit message from webhook payload"
    },
    {
      "type": "condition",
      "if": "branch == 'main'",
      "then": [
        {
          "type": "trigger-task",
          "task": "auto-deploy-from-git"
        }
      ]
    }
  ]
}

Payment Notification Handler

{
  "name": "payment-webhook",
  "trigger": "webhook",
  "webhook_path": "/webhooks/payment",
  "actions": [
    {
      "type": "ai-verify",
      "prompt": "Verify payment webhook signature and extract order details"
    },
    {
      "type": "shell",
      "command": "curl -X POST https://myapi.com/orders/${order_id}/paid"
    },
    {
      "type": "notification",
      "channel": "telegram",
      "message": "💰 Payment received: ${{amount}} for order #{{order_id}}"
    }
  ]
}

Use Case 6: Alert & Notification

Setup berbagai channel notifikasi untuk stay updated.

Konfigurasi Notification Channels

nano ~/openclaw/config/notifications.json
{
  "channels": {
    "telegram": {
      "enabled": true,
      "botToken": "${TELEGRAM_BOT_TOKEN}",
      "chatId": "${TELEGRAM_CHAT_ID}"
    },
    "slack": {
      "enabled": true,
      "webhookUrl": "${SLACK_WEBHOOK_URL}"
    },
    "email": {
      "enabled": true,
      "smtp": {
        "host": "smtp.gmail.com",
        "port": 587,
        "user": "${EMAIL_USER}",
        "pass": "${EMAIL_PASS}"
      },
      "from": "[email protected]",
      "to": "[email protected]"
    },
    "discord": {
      "enabled": true,
      "webhookUrl": "${DISCORD_WEBHOOK_URL}"
    }
  }
}

Advanced Use Cases

AI-Powered Log Analysis

{
  "name": "analyze-error-logs",
  "schedule": "0 * * * *",
  "actions": [
    {
      "type": "shell",
      "command": "tail -1000 /var/log/app/error.log",
      "output": "logs"
    },
    {
      "type": "ai-analyze",
      "prompt": "Analyze these error logs and identify patterns, critical issues, and suggest fixes",
      "input": "{{logs}}"
    },
    {
      "type": "condition",
      "if": "ai_response.severity == 'critical'",
      "then": [
        {
          "type": "notification",
          "channel": "telegram",
          "message": "🚨 Critical issues detected:\n{{ai_response.summary}}"
        }
      ]
    }
  ]
}

Auto-Scaling Decision

{
  "name": "intelligent-scaling",
  "schedule": "*/10 * * * *",
  "actions": [
    {
      "type": "metrics-collect",
      "sources": ["cpu", "memory", "network", "active_connections"]
    },
    {
      "type": "ai-decision",
      "prompt": "Based on these metrics, should we scale up, scale down, or maintain current resources?",
      "context": "{{metrics}}",
      "actions": {
        "scale_up": "trigger-scale-up-task",
        "scale_down": "trigger-scale-down-task",
        "maintain": "log-decision"
      }
    }
  ]
}

VPS yang Tepat untuk Automation

Untuk menjalankan berbagai automation task, kamu butuh VPS yang:

  • Selalu online — uptime 99.9%+
  • Resource stabil — tidak ngelag tiba-tiba
  • Network reliable — untuk webhook dan API calls
  • Storage cukup — untuk backup dan logs

🚀 VPS Indonesia Murah SufaNet

Perfect untuk automation workload dengan:

  • Uptime guarantee 99.9%
  • Resource dedicated (no throttling)
  • NVMe SSD — cepat untuk read/write logs
  • Network tier-1 Indonesia
  • Backup otomatis tersedia

Harga mulai dari Rp 50.000/bulan. Cukup untuk jalanin OpenClaw dengan 10-20 automation tasks concurrent.

Lihat Paket VPS Indonesia

Kalau butuh akses global atau target internasional:

🌏 VPS Singapore SufaNet

Lokasi strategis untuk automation global dengan latency rendah ke Asia-Pasifik, US, dan EU.

Lihat Paket VPS Singapore

FAQ

Berapa banyak task yang bisa dijalan concurrent?

Tergantung resource VPS dan complexity task. VPS 2GB RAM bisa handle 5-10 concurrent tasks. VPS 4GB bisa 15-20 tasks. Kalau butuh lebih banyak, consider upgrade atau distributed setup.

Apakah task bisa diprioritize?

Ya, OpenClaw support task priority. Task dengan priority tinggi akan dijalankan duluan kalau ada queue.

Bagaimana kalau task error?

OpenClaw punya retry mechanism, error handling, dan rollback support. Kamu bisa define berapa kali retry dan apa action kalau tetap gagal.

Apakah task bisa depend on task lain?

Ya, kamu bisa buat task dependency. Misalnya task B hanya jalan kalau task A sukses. Atau task C trigger setelah task A dan B selesai.

Bisakah satu webhook trigger multiple tasks?

Bisa! Satu webhook bisa trigger chain of tasks atau parallel tasks sekaligus.

Kesimpulan

OpenClaw adalah swiss army knife untuk automation di VPS Linux. Dari backup database, monitoring sistem, auto deployment, scheduled cleanup, sampai webhook integration—semua bisa di-automate dengan intelligent decision making dari AI.

Key takeaways:

  • Start simple — mulai dari task yang repetitive dan time-consuming
  • Add AI gradually — AI untuk decision making dan analysis
  • Monitor everything — setup notifikasi untuk stay informed
  • Test thoroughly — pastikan task jalan sesuai ekspektasi
  • Use right VPS — server stabil = automation reliable

👉 Langkah Selanjutnya

Automation yang solid dimulai dari server yang reliable.