Back to library
AI
tutorial

Automate Persistent Scheduled Tasks with the /loop Command

Automate recurring coding and system maintenance tasks that survive restarts.

Use the /loop slash command in Qwen Code to schedule recurring tasks that persist even after terminal restarts.

Qwen

The Scenario

You need to monitor a local server for specific error patterns every hour or perform a recurring data cleanup task within your project directory throughout the work week.

Before & after

The old way

Developers manually run scripts or check logs periodically, or spend 30-60 minutes setting up complex CRON jobs and environment variables that may break on system restart.

With AI

Run the /loop command in the Qwen Code terminal to schedule the task. The agent will execute it at defined intervals, even if you restart your computer or the terminal session, taking about 1 minute to set up.

The Prompt

/loop [INTERVAL_E_G_60M] [DESCRIBE_TASK_E_G_CHECK_FOR_NEW_LOG_ERRORS_AND_SUMMARIZE_THEM]

The /loop command in Qwen Code v0.18.0+ is designed for durable execution. Unlike standard terminal scripts that terminate when the session closes, these tasks survive restarts, making them ideal for long-term monitoring or repetitive maintenance.

Source

Qwen Code Blog: AI Coding Updates and Guides | Qwen Code Docs
"Durable /loop scheduled tasks surviving restart... launched Agent Team parallel collaboration."