For server administrators and developers who require scripts to execute automatically at designated times, the task scheduler facility provides a robust solution. This powerful feature enables the system to reliably run specified scripts, ensuring critical operations are performed without manual intervention.
Managing Scheduled Tasks in Plesk
To gain a comprehensive overview of all scheduled tasks, including those configured at both the individual subscription level and the server level, navigate to Tools & Settings > Scheduled Tasks (Cron jobs) within your Plesk control panel.
The scheduled tasks interface offers robust management capabilities. You can efficiently sort tasks by command, subscription, or schedule; this feature is particularly useful for diagnosing server load spikes, which might be attributed to resource-intensive scheduled tasks. For each task listed, you have the flexibility to modify its properties (by clicking on the task's name), activate it using the
icon, deactivate it via the
icon, or initiate an immediate execution of the task.
Important Note: Scheduled Task Shell Settings in Plesk for Linux
By default, in Plesk for Linux environments, scheduled tasks created by Plesk users are executed within a chrooted shell. This security-enhancing measure confines the file system root to the respective system user’s home directory. While this significantly boosts security, it also imposes certain limitations on Plesk users. To adjust the shell used for scheduled tasks across all Plesk users, access Tools & Settings > Scheduled Tasks > Settings. For a detailed explanation of these shell settings and their implications, please refer to the comprehensive guide on Scheduled tasks shell setting.
Creating and Configuring Scheduled Tasks
Creating a New Scheduled Task
To initiate the creation of a new scheduled task, navigate to Tools & Settings > Scheduled Tasks > Add Task. The initial step involves selecting the appropriate task type, which is determined by the specific objective you aim to achieve:
- Run a command: This option allows you to specify the full path to an executable file for execution. This category encompasses various file types, including binary executables, shell scripts, and batch files.
- Fetch a URL: For web-related tasks, simply provide the URL you wish to access. There is no need to manually type commands such as
curlorwget, as the system handles the fetching automatically. - Run a PHP script: Designed specifically for PHP applications, this option requires you to specify the full path to your PHP script, for instance:
/tmp/script.php.
Scheduling and Advanced Configuration
Once the task type is selected, proceed to define its execution frequency by specifying how often the task should run, along with the precise time and date. By default, task execution times are aligned with the server's local time zone. Should you require a different time zone for your scheduled tasks, you can adjust this setting under Tools & Settings > Scheduled Tasks > Settings. Additionally, the task configuration allows you to assign a descriptive name for easier identification, select the specific system user under whose security context the task will operate, and configure notification preferences to receive alerts regarding task completion or failures.
Testing Your Scheduled Task
Prior to finalizing and saving your scheduled task, it is highly recommended to perform a test run. This crucial step ensures that the task is correctly configured and will execute as expected. To do so, simply click the Run Now button and allow the task to complete its execution. It is important to note that if the test run concludes with an error, the task will similarly fail when automatically executed by the scheduler. Therefore, any detected issues should be thoroughly investigated and resolved before relying on the automated schedule.
