Skip to main content

Overview

PhoneClaw’s scheduler lets you run automations automatically at specific times or recurring intervals using cron expressions. This is perfect for social media posting, periodic data checks, or any task that needs to run without manual intervention.
Scheduled tasks run in the background even when PhoneClaw isn’t actively open. The scheduler checks for tasks every minute and executes them according to their cron schedule.

The schedule() Function

Schedule tasks using the ClawScript schedule() function:
Parameters:
  • taskDescription (string): A description or reference to your automation task
  • cronExpression (string): A cron expression defining when to run
Example:

Creating Scheduled Tasks

Understanding Cron Expressions

Cron expressions define when tasks run using 5 time fields:

Special Characters

  • * - Any value (every minute, every hour, etc.)
  • , - Value list separator (1,15,30)
  • - - Range of values (1-5)
  • / - Step values (*/15 = every 15 units)

Common Cron Patterns

Every Hour

Every 30 Minutes

Every Day at 9 AM

Every Weekday at 8 AM

Every Monday at Noon

Twice Daily (9 AM and 6 PM)

First Day of Every Month

Every 15 Minutes During Work Hours

Use crontab.guru to test and validate your cron expressions with human-readable descriptions.

Real-World Scheduling Examples

Social Media Posting

Post to multiple platforms throughout the day:

Email Check Every 10 Minutes

Nightly Backup

Weekend Morning Routine

Combining Multiple Schedules

Run different tasks on different schedules:

Managing Scheduled Tasks

View All Tasks

From the MainActivity code, scheduled tasks are stored with:

Task Status

Each task shows:
  • Created At: When the schedule was created
  • Last Executed: When it last ran
  • Next Run: Calculated from cron expression
  • Active Status: Whether it’s currently enabled

Disable vs Delete

To temporarily pause without deleting:
clearSchedule() removes ALL scheduled tasks. There’s no way to selectively remove individual tasks in the current ClawScript API.

Scheduler Behavior

How the Scheduler Works

From the PhoneClaw source code:
  1. Cron Checker runs continuously in a coroutine
  2. Checks every minute if any tasks are due
  3. Compares current time against cron expressions
  4. Executes matching tasks
  5. Updates lastExecuted timestamp
  6. Schedules next check

Execution Guarantees

  • Tasks run within 1 minute of scheduled time
  • If the device is asleep, tasks run when it wakes
  • Missed tasks don’t run retroactively
  • Only one instance of a task runs at a time

Battery Considerations

Frequent scheduled tasks can drain battery. Use reasonable intervals:
  • Every 5+ minutes is generally safe
  • Every 1-2 minutes may impact battery life
  • Every few seconds is not recommended for production

Debugging Scheduled Tasks

Test Your Cron Expression

Before scheduling, verify your cron works:

Add Logging

Include speech feedback to confirm execution:

Check Last Execution

View the Scheduled Tasks tab to see:
  • When the task last ran
  • If it’s running on schedule
  • Any execution errors

Best Practices

Use Reasonable Intervals

Add Error Handling

Clear Old Schedules

Before creating new schedules, clear old ones:

Use Descriptive Names

Troubleshooting

Task Not Running

  • Verify cron expression at crontab.guru
  • Check device isn’t in aggressive battery saving mode
  • Ensure PhoneClaw accessibility service is enabled
  • Check Scheduled Tasks tab for error messages

Task Runs at Wrong Time

  • Verify device time zone is correct
  • Cron uses 24-hour format (0-23 for hours)
  • Day of week: 0 and 7 both mean Sunday
  • Check if you meant AM vs PM

Multiple Tasks Conflict

  • Stagger schedules by a few minutes
  • Don’t schedule two tasks at exact same time
  • Add delays between app switches

Battery Drain

  • Reduce task frequency
  • Combine multiple checks into one task
  • Schedule during specific hours only
  • Use */15 instead of */5 for intervals

Next Steps

Multi-App Workflows

Chain scheduled tasks across apps

ClawScript Functions

See all available automation functions

Voice Commands

Generate schedules with voice