Tasker Examples
These examples show complete Tasker task configurations for common ZestSSH automation scenarios. Replace YOUR_KEY with your actual API key and connection labels with your own.
Example 1: Daily Server Health Check
Section titled “Example 1: Daily Server Health Check”Goal: Every morning, check disk usage on a web server and notify if above 80%.
Tasker Profile
Section titled “Tasker Profile”- Trigger: Time > Every Day at 07:00
Tasker Task: “Server Health”
Section titled “Tasker Task: “Server Health””Action 1 --- Browse URL:
URL: zestssh://execute?connection=WebServer&command=df -h / | awk 'NR==2{print $5}' | tr -d '%'&key=YOUR_KEY&timeout=15Action 2 --- Wait: 5 seconds (allow ZestSSH to execute)
Action 3 --- Variable Set:
- Name:
%disk_usage - To:
%stdout
Action 4 --- If: %disk_usage > 80
Action 5 --- Notify:
- Title: “Disk Warning”
- Text: “WebServer disk at %disk_usage%”
Action 6 --- End If
Alternative Using Intent (More Reliable Result Handling)
Section titled “Alternative Using Intent (More Reliable Result Handling)”Action 1 --- Send Intent:
- Action:
com.affluentlabs.zestssh.EXECUTE - Extra:
connection_id:WebServer - Extra:
command:df -h / | awk 'NR==2{print $5}' | tr -d '%' - Extra:
key:YOUR_KEY - Extra:
timeout:15 - Target: Service
The intent returns %stdout with the disk percentage and %exit_code with 0 or 1.
Example 2: Backup Trigger on Wi-Fi Disconnect
Section titled “Example 2: Backup Trigger on Wi-Fi Disconnect”Goal: When you leave home (disconnect from home Wi-Fi), trigger a backup script on your NAS.
Tasker Profile
Section titled “Tasker Profile”- Trigger: State > Net > Wi-Fi Connected
- Invert: Yes (triggers on disconnect)
- SSID: “HomeNetwork”
Tasker Task: “Trigger NAS Backup”
Section titled “Tasker Task: “Trigger NAS Backup””Action 1 --- Browse URL:
URL: zestssh://execute?connection=NAS&command=sudo /opt/scripts/backup.sh&key=YOUR_KEY&timeout=600Action 2 --- Notify:
- Title: “Backup Started”
- Text: “NAS backup triggered (leaving home)“
With Webhook Callback
Section titled “With Webhook Callback”To receive a notification when the backup finishes:
URL: zestssh://execute?connection=NAS&command=sudo /opt/scripts/backup.sh&key=YOUR_KEY&timeout=600&callback=https://ntfy.sh/your-backup-topicThe callback posts results to ntfy.sh (or any HTTPS endpoint) so you get a push notification when the backup completes.
Example 3: Deploy Script with Branch Variable
Section titled “Example 3: Deploy Script with Branch Variable”Goal: Trigger a deployment to staging with a specific branch, using a snippet with variable substitution.
Setup in ZestSSH
Section titled “Setup in ZestSSH”Create a snippet named “deploy-branch” with the command:
cd /var/www/app && git fetch && git checkout {{branch}} && git pull && docker compose up -d --buildTasker Task: “Deploy to Staging”
Section titled “Tasker Task: “Deploy to Staging””Action 1 --- Variable Set:
- Name:
%deploy_branch - To:
develop(or prompt with Input Dialog)
Action 2 --- Browse URL:
URL: zestssh://snippet?connection=StagingServer&name=deploy-branch&var_branch=%deploy_branch&key=YOUR_KEYAction 3 --- Notify:
- Title: “Deploy Triggered”
- Text: “Deploying %deploy_branch to staging”
Example 4: Multi-Server Update
Section titled “Example 4: Multi-Server Update”Goal: Run apt update && apt upgrade -y on three servers simultaneously.
Tasker Task: “Patch All Servers”
Section titled “Tasker Task: “Patch All Servers””Action 1 --- Browse URL:
URL: zestssh://batch?connections=Web1,Web2,DB1&command=sudo apt update -qq && sudo apt upgrade -y -qq&key=YOUR_KEY¶llel=true&timeout=120The batch action runs the command on all three servers concurrently. The combined output shows results per server.
Action 2 --- Send Intent (for result):
- Action:
com.affluentlabs.zestssh.EXECUTE - Extra:
connection_id:Web1 - Extra:
command:cat /var/run/reboot-required 2>/dev/null && echo "REBOOT NEEDED" || echo "No reboot needed" - Extra:
key:YOUR_KEY
Action 3 --- If: %stdout ~ REBOOT NEEDED
Action 4 --- Notify:
- Title: “Reboot Required”
- Text: “Web1 needs a reboot after updates”
Action 5 --- End If
Example 5: Container Status Monitoring
Section titled “Example 5: Container Status Monitoring”Goal: Every hour, check if key Docker containers are running and alert if any are down.
Tasker Profile
Section titled “Tasker Profile”- Trigger: Time > Every 1 Hour
Tasker Task: “Check Containers”
Section titled “Tasker Task: “Check Containers””Action 1 --- Browse URL:
URL: zestssh://execute?connection=DockerHost&command=docker ps --format '{{.Names}} {{.Status}}' | grep -v "Up"&key=YOUR_KEY&timeout=15The grep -v "Up" filters to show only containers that are NOT running.
Action 2 --- Wait: 3 seconds
Action 3 --- If: %stdout is set (non-empty means some containers are down)
Action 4 --- Notify:
- Title: “Container Alert”
- Text: “Containers down:\n%stdout”
- Priority: High
Action 5 --- End If
Using Output Filters
Section titled “Using Output Filters”Instead of putting grep in the command itself, you can use ZestSSH’s built-in output filter:
URL: zestssh://execute?connection=DockerHost&command=docker ps --format '{{.Names}} {{.Status}}'&grep=Exited&key=YOUR_KEYThe grep=Exited parameter filters the output to show only containers with “Exited” in their status line.
Tips for Tasker Integration
Section titled “Tips for Tasker Integration”- Use Variable Set to store the API key once and reference
%zest_keyin all tasks, rather than pasting the raw key into every URL. - URL encoding: Tasker handles basic URL encoding, but complex commands with special characters (
&,=,%) may need manual encoding. Use%26for&,%3Dfor=in command strings. - Wait actions: When using Browse URL, add a short Wait action (3-5 seconds) before checking results, since Browse URL returns immediately after opening the URL.
- Intent method is more reliable for result handling. The Browse URL method is simpler to set up but does not reliably return stdout to Tasker variables.
- Test commands manually in ZestSSH’s terminal before automating them to make sure they produce the expected output.