DEV Community

Samuel James Hiotis
Samuel James Hiotis

Posted on

Zero-capital automation: running a business from Termux

Zero-Capital Automation: Running a Business From Termux

Okay, so you want to start a business. Great! But maybe you’re strapped for cash. Maybe you’re avoiding the whole ‘investment’ phase, or just want to validate an idea before pouring money in. I’ve been there. And I’ve found a surprisingly powerful, and incredibly cheap, way to do it: Termux on Android.

Seriously. Your phone.

For the past six months, I’ve been running a small (and growing!) business entirely from my phone, leveraging Termux for automation. It's not just about sending emails – it's about building systems that require minimal ongoing effort. This isn't a "get rich quick" scheme, it's a practical breakdown of how you can build a lean, automated operation with effectively zero capital. Let's dive in.

What is Termux?

Think of Termux as a Linux distribution built for Android. It provides a terminal environment where you can install packages, run scripts, and generally act like you’re on a full-fledged Linux machine. It's not root access, but it's shockingly capable. Download it from F-Droid (recommended - keeps it updated automatically) or the Google Play Store.

Why Termux for Business?

The beauty is multi-faceted:

  • Cost: It’s free. Your phone you likely already own. That’s your server.
  • Portability: Business on the go. Literally. I've edited scripts on trains, responded to alerts from cafes.
  • Automation Potential: Python, Node.js, Bash scripting – it's all there. You can automate almost anything.
  • Privacy: Less reliance on cloud services, more control over your data (though backups are crucial - more on that later).
  • Learning: You’ll learn a ton about system administration and scripting.

My Use Case: Automated Data Scraping & Report Generation

My business, in a nutshell, aggregates data from various public sources (think real estate listings, job boards, etc.) and provides summarized reports to clients. It’s a niche, but a good example of how Termux shines.

The Tech Stack (All inside Termux)

  • Python 3: The core language.
  • requests & BeautifulSoup4: For web scraping.
  • schedule: For scheduling tasks (essential for automation).
  • smtplib & email.mime: For sending emails.
  • tqdm: For progress bars (makes long tasks less scary).
  • sqlite3: For lightweight database management.
  • Bash Scripting: For orchestrating everything and handling background processes.
  • Termux:API: For accessing phone features (optional, but useful for notifications).

Let’s look at some code. This is a simplified example, but demonstrates the principle:

# scrape_data.py
import requests
from bs4 import BeautifulSoup
import sqlite3
import time
from tqdm import tqdm

def scrape_website(url):
  """Scrapes data from a given URL and returns a list of dictionaries."""
  try:
    response = requests.get(url)
    response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
    soup = BeautifulSoup(response.content, 'html.parser')
    #  ... (Your scraping logic here - replace with your target website's HTML structure) ...
    # This is a placeholder - you'll need to adapt it!
    data = []
    for item in soup.find_all('div', class_='item'):
      title = item.find('h2').text.strip()
      price = item.find('span', class_='price').text.strip()
      data.append({'title': title, 'price': price})
    return data
  except requests.exceptions.RequestException as e:
    print(f"Error scraping {url}: {e}")
    return []

def save_to_db(data):
  """Saves data to an SQLite database."""
  conn = sqlite3.connect('data.db')
  cursor = conn.cursor()
  cursor.execute('''
    CREATE TABLE IF NOT EXISTS scraped_data (
      title TEXT,
      price TEXT
    )
  ''')
  for item in data:
    cursor.execute("INSERT INTO scraped_data (title, price) VALUES (?, ?)", (item['title'], item['price']))
  conn.commit()
  conn.close()

if __name__ == "__main__":
  target_url = "https://example.com/listings"  # Replace with your target website
  scraped_data = tqdm(scrape_website(target_url), desc="Scraping")
  save_to_db(list(scraped_data))
  print("Data scraped and saved to data.db")
Enter fullscreen mode Exit fullscreen mode

This script scrapes a (placeholder) website, extracts some data, and saves it to an SQLite database. Notice the tqdm for a progress bar - incredibly useful when scripts run for a while.

Automation with schedule and Bash

Now, let's automate this. I use a Bash script to schedule the Python script to run daily.

#!/bin/bash

# schedule_script.sh
while true; do
  date
  python /data/data/com.termux/files/home/scrape_data.py  # Replace with your script's path
  sleep 86400 # Sleep for 24 hours (in seconds)
done
Enter fullscreen mode Exit fullscreen mode

Important: This script runs forever. To run it in the background, use:

nohup ./schedule_script.sh &
Enter fullscreen mode Exit fullscreen mode

nohup makes the script ignore hangup signals (so it continues running when you close Termux), and & puts it in the background.

Sending Reports via Email

After scraping and saving, I generate a report from the database and email it to clients. Again, using Python within Termux:


python
# generate_report.py
import sqlite3
import smtplib
from email.mime.text import MIMEText

def generate_report():
  """Generates a report from the database."""
  conn = sqlite3.connect('data.db')
  cursor = conn.cursor()
  cursor.execute("SELECT * FROM scraped_data")
  data = cursor.fetchall()
  conn.close()

  report_body = "<h1>Daily Report</h1><ul>"
  for row in data:
    report_body += f"<li><b>{row[0]}</b> - {row[1]}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)