How to setup a Cron job in Staq
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:
- Secure Context: All jobs run within WordPress root, boosting security.
- 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.
- WP CLI: Execute WP CLI commands like
Chaining multiple commands using ‘&&’ is allowed, as long as each command adheres to the designated rules and conditions.
Need some help?
We all do sometimes. Please reach out to our support team by dropping us a support ticket. We will respond fast.