The task.checkStatus method retrieves the status of a script based on its task ID. A Scheduled or Map/Reduce script typically has the following possible statuses:
- PENDING: Scheduled to run but not yet started.
- PROCESSING: Actively running.
- QUEUED: Waiting in queue due to load or resource allocation.
const taskStatus = task.checkStatus({ taskId: taskid }); // Check if the script is in a running state if (taskStatus.status === task.TaskStatus.PENDING || taskStatus.status === task.TaskStatus.PROCESSING || taskStatus.status === task.TaskStatus.QUEUED) { log.debug('Script Status', 'Script is currently running.');