Quick guide to reclaim space and automate disk maintenance for n8n running in Docker on DigitalOcean Droplets. คู่มือด่วนสำหรับเพิ่มพื้นที่และตั้งค่าบำรุงรักษาดิสก์อัตโนมัติบน Droplet ที่รัน n8n Docker
🔧 Command Generator🔧 เครื่องมือสร้างคำสั่ง
Generate custom commands with your specific paths and settings. สร้างคำสั่งที่กำหนดเองด้วย path และการตั้งค่าของคุณ
Navigate to n8n Directory
ไปยังโฟลเดอร์ n8n
Your navigation and restart commands will appear here.
Note: Use xfs_growfs / for XFS filesystem. หมายเหตุ: ใช้ xfs_growfs / สำหรับไฟล์ระบบ XFS
3. Manual Docker Cleanup3. ล้าง Docker ด้วยตนเอง
docker system prune -af --volumes
Warning: This will remove all unused containers, networks, images, and volumes. คำเตือน: คำสั่งนี้จะลบ containers, networks, images และ volumes ที่ไม่ได้ใช้ทั้งหมด
4. Configure Daily Cron Jobs4. ตั้งค่า Cron Jobs รายวัน
Open crontab editor / เปิดตัวแก้ไข crontab
sudo crontab -e
First time? You'll be asked to choose an editor. Select nano (usually option 1) for beginners. ครั้งแรก? จะถูกถามให้เลือกตัวแก้ไข เลือก nano (มักจะเป็นตัวเลือก 1) สำหรับผู้เริ่มต้น
How to paste: Use Ctrl+Shift+V or right-click and paste. Go to the bottom of the file and add these lines. วิธีวาง: ใช้ Ctrl+Shift+V หรือคลิกขวาแล้ววาง ไปที่ท้ายไฟล์และเพิ่มบรรทัดเหล่านี้
Safety first! This creates a backup in case something goes wrong. ความปลอดภัยก่อน! สร้างไฟล์สำรองกรณีมีปัญหา
Edit the docker-compose.yml file / แก้ไขไฟล์ docker-compose.yml
nano docker-compose.yml
Find the environment section / หาส่วน environment
Look for a section like this: environment: - N8N_HOST=... - N8N_PORT=... หาส่วนที่มีลักษณะแบบนี้: environment: - N8N_HOST=... - N8N_PORT=...
Add these two lines / เพิ่มสองบรรทัดนี้
- N8N_PRUNE_DATA=true
- N8N_PRUNE_DATA_MAX_AGE=14
Add at the end of the environment section. Make sure the spacing matches other lines (6 spaces before the dash). เพิ่มที่ท้าย ของส่วน environment ให้แน่ใจว่าการเว้นวรรคตรงกับบรรทัดอื่น (6 ช่องว่างก่อนเครื่องหมายขีด)
Save and exit / บันทึกและออก
Press Ctrl+X, then Y, then Enter
Restart n8n containers / รีสตาร์ท n8n containers
docker compose down && docker compose up -d
This stops and starts n8n with the new settings. It may take 1-2 minutes. คำสั่งนี้หยุดและเริ่ม n8n ด้วยการตั้งค่าใหม่ อาจใช้เวลา 1-2 นาที
This step is required! Without this, the script won't run automatically. ขั้นตอนนี้จำเป็น! ถ้าไม่ทำ สคริปต์จะไม่รันอัตโนมัติ
Add cron job / เพิ่ม cron job
sudo crontab -e
Add this line at the bottom / เพิ่มบรรทัดนี้ที่ท้ายไฟล์
15 6 * * * /root/send_logs_to_n8n.sh
This runs at 06:15 daily - 15 minutes after the disk logging, so all logs are ready. จะรันเวลา 06:15 ทุกวัน - 15 นาทีหลังจากบันทึกดิสก์ เพื่อให้ log ทั้งหมดพร้อม