Ctrl K
ring2all.com

Custom Tasks Module Documentation

Table of Contents

  1. Module Overview (Technical)
  2. Module Overview (Commercial/Business)
  3. Module Overview (End User/Administrator)
  4. Configuration Sections
  5. Settings Reference
  6. Common Scenarios & Examples
  7. Limitations & Important Notes
  8. Troubleshooting Tips
  9. Glossary

---

1. Module Overview (Technical)

What Are Custom Tasks?

Custom Tasks is a task scheduler module that manages execution of custom scripts. It allows scheduling scripts with cron profiles, setting execution parameters, tracking run history, and triggering manual execution.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Custom Tasks Architecture                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Custom Scripts                                                 │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │  /opt/r2a/scripts/custom/                               │   │
│  │                                                          │   │
│  │  ├── daily-report.sh                                    │   │
│  │  ├── sync-contacts.py                                   │   │
│  │  ├── cleanup-temp.sh                                    │   │
│  │  └── export-data.sh                                     │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ Referenced by tasks                                    │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        Custom Tasks                                      │   │
│  │                                                          │   │
│  │  Task: Daily Report                                      │   │
│  │  ┌────────────────────────────────────────────────────┐  │   │
│  │  │  Script: daily-report.sh                           │  │   │
│  │  │  Args: --format=pdf --email=admin@company.com     │  │   │
│  │  │  Cron Profile: Daily Midnight                      │  │   │
│  │  │  Timeout: 300 seconds                              │  │   │
│  │  │  Run As: root                                      │  │   │
│  │  │  Status: ● Enabled                                 │  │   │
│  │  └────────────────────────────────────────────────────┘  │   │
│  │                                                          │   │
│  │  Task: Contact Sync                                      │   │
│  │  ┌────────────────────────────────────────────────────┐  │   │
│  │  │  Script: sync-contacts.py                          │  │   │
│  │  │  Cron Profile: Every 15 Min                        │  │   │
│  │  │  Status: ● Enabled                                 │  │   │
│  │  └────────────────────────────────────────────────────┘  │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼ Execution results                                      │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        Execution History                                 │   │
│  │                                                          │   │
│  │  Run 1: Jan 16 00:00 | Success | 12s | Exit: 0          │   │
│  │  Run 2: Jan 15 00:00 | Success | 14s | Exit: 0          │   │
│  │  Run 3: Jan 14 00:00 | Failed  | 300s| Exit: 1          │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Tables

TablePurpose
public.custom_tasksTask configurations
public.custom_task_executionsRun history

Key Files

FileDescription
modules/customTasks/Frontend module
/opt/r2a/scripts/custom/Script location
---

2. Module Overview (Commercial/Business)

Business Value

Custom Tasks provides automated script management:

Without ModuleWith Module
Manual cronWeb interface
No visibilityExecution tracking
CLI onlyGUI management
No historyRun history

Use Cases

  1. Automation
- Report generation

- Data synchronization

  1. Maintenance
- Cleanup scripts

- Health checks

  1. Integration
- API calls

- Data exports

  1. Monitoring
- Status checks

- Alert scripts

Feature Highlights

FeatureBenefit
Script SelectionDropdown from folder
Cron IntegrationUse Cron Profiles
ArgumentsPass script params
TimeoutPrevent runaway
Run As UserSecurity control
Execute NowManual trigger
HistoryView past runs
---

3. Module Overview (End User/Administrator)

What Can You Do?

  • Create scheduled tasks
  • Select scripts to run
  • Set execution schedule
  • Configure arguments
  • Set timeout limits
  • View execution history
  • Run tasks manually
  • Track success/failure

Custom Tasks - List View

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Custom Tasks                                       │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Manage scheduled custom script executions                     │
│                                                                 │
│  [+ Create Task]                                                │
│                                                                 │
│  [🔍 Search tasks...]                                           │
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ Name         │ Script       │ Schedule    │ Last Run│ St │  │
│  ├──────────────┼──────────────┼─────────────┼─────────┼────┤  │
│  │ Daily Report │ daily-report │ Daily       │ Today   │ ✓  │  │
│  │ Contact Sync │ sync-contacts│ Every 15min │ 10 min  │ ✓  │  │
│  │ Cleanup Temp │ cleanup-temp │ Weekly      │ Jan 14  │ ✓  │  │
│  │ Manual Task  │ export-data  │ Manual      │ Never   │ ●  │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  Actions: [▶ Execute] [📋 History] [✏️ Edit] [🗑️ Delete]       │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Create/Edit Task

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Create Custom Task                                 │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  [General] [Execution]                                          │
│                                                                 │
│  ▼ General Information                                          │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                                                             ││
│  │  Task Name: [Daily Report                    ]             ││
│  │                                                             ││
│  │  Description: [Generate and email daily stats ]            ││
│  │                                                             ││
│  │  Enabled: ✓                                                ││
│  │                                                             ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Script Configuration                                         │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                                                             ││
│  │  Script: [daily-report.sh ▼]                               ││
│  │    Scripts are located in /opt/r2a/scripts/custom/         ││
│  │                                                             ││
│  │  Script Arguments: [--format=pdf --email=admin@co.com]     ││
│  │    Optional arguments to pass to the script                 ││
│  │                                                             ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Schedule                                                     │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                                                             ││
│  │  Cron Profile: [Daily Midnight ▼]                          ││
│  │    Leave empty for manual execution only                    ││
│  │                                                             ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  ▼ Execution Settings                                           │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │                                                             ││
│  │  Timeout (seconds): [300              ]                    ││
│  │    Maximum execution time (1-86400 seconds)                 ││
│  │                                                             ││
│  │  Run As User: [root                   ]                    ││
│  │    System user to run the script as                         ││
│  │                                                             ││
│  └─────────────────────────────────────────────────────────────┘│
│                                                                 │
│  [Save] [Cancel]                                                │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Execution History

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Execution History - Daily Report                   │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ Date/Time        │ Trigger │ Duration│ Exit Code│ Status │  │
│  ├──────────────────┼─────────┼─────────┼──────────┼────────┤  │
│  │ Jan 16 00:00:15  │ Cron    │ 12s     │ 0        │ ✓ Success│ │
│  │ Jan 15 00:00:12  │ Cron    │ 14s     │ 0        │ ✓ Success│ │
│  │ Jan 15 14:30:00  │ Manual  │ 8s      │ 0        │ ✓ Success│ │
│  │ Jan 14 00:00:10  │ Cron    │ 300s    │ 1        │ ✗ Failed │ │
│  │ Jan 13 00:00:14  │ Cron    │ 11s     │ 0        │ ✓ Success│ │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                 │
│  Click row to view output                                       │
│                                                                 │
│  [Close]                                                        │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Quick Tips

TIP
Script Location: Place scripts in /opt/r2a/scripts/custom/
TIP
Manual Only: Leave Cron Profile empty for on-demand tasks.
WARNING
Timeout: Set appropriate timeout to prevent runaway scripts.

---

4. Configuration Sections

General Information

FieldDescription
Task NameTask identifier
DescriptionTask purpose
EnabledActive/Inactive

Script Configuration

FieldDescription
ScriptScript file to execute
Script ArgumentsCommand line args

Schedule

FieldDescription
Cron ProfileSchedule (or empty = manual)

Execution Settings

FieldDescription
TimeoutMax run time (seconds)
Run As UserExecution user
---

5. Settings Reference

Execution Status

StatusDescription
SuccessExit code 0
FailedNon-zero exit code
RunningCurrently executing
TimeoutExceeded time limit
KilledManually stopped
Never RunNot yet executed

Trigger Types

TriggerDescription
ScheduledCron profile triggered
ManualExecute Now button
APIAPI call triggered

Timeout Values

ValueUse Case
60Quick scripts
300Standard (5 min)
3600Long-running (1 hr)
86400Very long (24 hr max)

Common Script Types

TypeExtensionDescription
Bash.shShell scripts
Python.pyPython scripts
Perl.plPerl scripts
Node.jsNode.js scripts
---

6. Common Scenarios & Examples

Scenario 1: Create Daily Report Task

  1. Click Create Task
  2. Name = "Daily Report"
  3. Script = daily-report.sh
  4. Args = "--format=pdf --email=admin@company.com"
  5. Cron Profile = Daily Midnight
  6. Timeout = 300
  7. Run As User = root
  8. Save

Scenario 2: Manual-Only Task

  1. Create Task
  2. Name = "Export Data"
  3. Script = export-data.sh
  4. Cron Profile = (leave empty)
  5. Save
  6. Execute Now when needed

Scenario 3: High-Frequency Sync

  1. Create Task
  2. Name = "CRM Sync"
  3. Script = sync-crm.py
  4. Cron Profile = Every 5 Minutes
  5. Timeout = 240 (allow time before next)
  6. Save

Scenario 4: Debug Failed Task

  1. Go to task list
  2. Click failed task
  3. Click View History
  4. Click failed execution
  5. View output and exit code
  6. Fix script issue
  7. Execute Now to verify

---

7. Limitations & Important Notes

Technical Notes

NOTE
Script Location: Scripts must be in /opt/r2a/scripts/custom/
NOTE
Executable: Scripts must be executable (chmod +x)
WARNING
Security: Run As User controls script permissions.

Best Practices

  1. Test Scripts: Test locally before adding
  2. Set Timeout: Prevent runaway processes
  3. Log Output: Scripts should output status
  4. Exit Codes: Use 0 for success, non-zero for failure
  5. Descriptive Names: Clear task naming

Script Requirements

RequirementDetails
Location/opt/r2a/scripts/custom/
PermissionsExecutable (chmod +x)
ShebangInclude #!/bin/bash or similar
Exit CodeReturn 0 for success
OutputStdout captured in history

Example Script Template

Bash
#!/bin/bash
# Script: daily-report.sh
# Description: Generate daily report

set -e  # Exit on error

echo "Starting daily report generation..."

# Your logic here

echo "Report generated successfully"
exit 0

---

8. Troubleshooting Tips

Common Issues

SymptomPossible CauseSolution
Script not listedNot in folderMove to custom folder
Permission deniedNot executablechmod +x script.sh
TimeoutScript too slowIncrease timeout
Failed statusScript errorCheck output/exit code

Check Script Status

Bash
# List available scripts
ls -la /opt/r2a/scripts/custom/

# Test script manually
sudo /opt/r2a/scripts/custom/daily-report.sh --arg

# Check permissions
ls -la /opt/r2a/scripts/custom/daily-report.sh

Debug Script

Bash
# Run with debug output
bash -x /opt/r2a/scripts/custom/script.sh

# Check exit code
/opt/r2a/scripts/custom/script.sh
echo $?

---

9. Glossary

TermDefinition
TaskScheduled script execution
ScriptExecutable file
Cron ProfileSchedule template
TimeoutMax execution time
Exit CodeScript return value
ExecutionSingle run of task
---

Lua Script Status ℹ️

Automation Module

ComponentStatus
Custom Tasksℹ️ Script scheduler - no Lua handler required
Custom Tasks is an automation module. It schedules and executes custom scripts. No Lua handlers are used - script execution is managed by the backend scheduler.

---

Documentation last updated: January 2026
AI Assistant

👋 Hello! I'm your Ring2All documentation assistant. I can help you find information about configuring and using the Ring2All PBX platform.

How can I help you today?