HestiaCP is an open-source control panel that lets you manage websites, email, databases and much more. Among its features is the option to configure tasks to run at regular intervals. These tasks are very similar to the cron jobs used by GNU/Linux distributions.
Below, we explain how to configure tasks in HestiaCP, fill in all the required details and check that they run correctly.
Task basics
For each user in HestiaCP, you have the Tareas option. For example, the default admin user has its own tasks:
These tasks mainly ensure that HestiaCP runs properly: they update panel data, create user backups, update statuses, check for available updates, etc.
A new user will probably have no tasks, but you can add one by clicking the Añadir Tarea Programada button:
Below, we explain what each parameter means for tasks:
- Comando: The command to run. Enter the absolute path to the command followed by the absolute path to the file to run. If you do not know the absolute path to the command, you can connect to the server via SSH and run the command: whereis [comando] (for example: whereis php8.1).
- Minuto: The minute when the task should run.
- Hora: The hour when the task should run.
- Día: The days when the task should run.
- Mes: The month when the task should run.
- Día de la semana: The days of the week when the task should run.
When to run the task
In HestiaCP, you can automatically configure when you want the task to run by simply opening the drop-down menu and selecting a time. If you need something more specific, you can use Crontab.guru.
Add a task to run PHP files
To add a task to run a PHP file, enter the following:
Find the absolute path to the command
Remember that the command to run a PHP script is php8.1 (for PHP version 8.1; if you use another version, enter the appropriate command), and you need its absolute path. To find it, connect to the server via SSH and run the following:
$ whereis php8.1
bash: /usr/bin/php8.1
Add a task to run Bash files
To add a task to run a BASH file, enter the following:
Find the absolute path to the command
Remember that the command to run a BASH script is bash, and you need its absolute path. To find it, connect to the server via SSH and run the following:
$ whereis bash
bash: /usr/bin/bash
Add a task to run Python files
To add a task to run a Python file, enter the following:
Find the absolute path to the command
Remember that the command to run a Python script is python3, and you need its absolute path. To find it, connect to the server via SSH and run the following:
$ whereis python3
python3: /usr/bin/python3
Add a task to run NodeJS files
To add a task to run a NodeJS file, enter the following:
Find the absolute path to the command
Remember that the command to run a NodeJS script is node, and you need its absolute path. To find it, connect to the server via SSH and run the following:
$ whereis node
node: /usr/bin/node
Check that your task runs correctly
To check that your task is running correctly, connect to the server via SSH and review the log file /var/log/syslog.
To check that the task runs correctly, use the grep command to filter for different keywords.
For example, search for the user running it (which is the HestiaCP user):
grep CRON /var/log/syslog | grep adminOr search for the file name:
grep crontab.php /var/log/syslogThese two commands should display something similar to this:
Jul 11 11:18:01 hestia CRON[76648]: (admin) CMD (sudo /usr/local/hestia/bin/v-update-sys-queue restart)
Jul 11 11:20:01 hestia CRON[77110]: (admin) CMD (sudo /usr/local/hestia/bin/v-update-sys-queue backup)
Jul 11 11:20:01 hestia CRON[77111]: (admin) CMD (sudo /usr/local/hestia/bin/v-update-sys-queue restart)
Jul 11 11:20:01 hestia CRON[77112]: (admin) CMD (sudo /usr/local/hestia/bin/v-update-sys-rrd)
Jul 11 11:20:01 hestia CRON[77115]: (admin) CMD (/usr/bin/php8.1 /home/admin/web/laravel.com/public_html/crontab.php)
Jul 11 11:22:01 hestia CRON[77421]: (admin) CMD (sudo /usr/local/hestia/bin/v-update-sys-queue restart)
Jul 11 11:22:01 hestia CRON[77422]: (admin) CMD (/usr/bin/php8.1 /home/admin/web/laravel.com/public_html/crontab.php)
Jul 11 11:24:01 hestia CRON[77482]: (admin) CMD (sudo /usr/local/hestia/bin/v-update-sys-queue restart)
Jul 11 11:24:01 hestia CRON[77483]: (admin) CMD (/usr/bin/php8.1 /home/admin/web/laravel.com/public_html/crontab.php)