How to setup a Cron job in Staq

Table of Contents
    square-for-kb1
    cron-manager

    Cron jobs are essential for automating tasks in WordPress. The WordPress cron system is reliant on user interactions with the website. This means that scheduled tasks are only executed when a user accesses the site, causing delays.

    To have better control when CRON jobs operate, it is recommended that you go to Staq Panel for the site in question, and click WP Config File:

    Click Add and add DISABLE_WP_CRON as the name and the value as true

    Then, go back to Staq Panel and click Cron Manager:

    From there, you can add your desired commands based on the interval.

    Staq Cron Manager uses Linux Crontab Syntax.

    If you select Custom and do not know how to format your command, you can use this Crontab Generator

     

    Staq’s Approach

    Staq introduces a unique system for cron jobs, ensuring security and efficiency. Each Staq-hosted site operates in its own Linux user environment, having an individual crontab. This empowers users to integrate server cron jobs seamlessly.

    Utilizing Staq’s Cron Jobs

    Staq simplifies scheduled task management with key features:

    1. Secure Context: All jobs run within WordPress root, boosting security.
    2. Supported Commands:
      • WP CLI: Execute WP CLI commands like wp option delete cron.
      • wget / curl: Download files to WordPress directory, e.g., wget https://mydomain.com/data -P ./wp-content/data/.
      • PHP Execution: Run PHP files using php -f [filepath], relative to WordPress root.
      • File Permissions: Modify file permissions using chmod on relative paths.
      • Change Directory: Change directory using cd on relative paths.

    Chaining multiple commands using ‘&&’ is allowed, as long as each command adheres to the designated rules and conditions.

    Try Staq
    Everything WordPress in one place. Simplify WordPress, streamline your flow
    square-for-kb3