If you need to run scripts on your server at specific time, use the task
scheduler facility on your server to make the system automatically run
the scripts for you.
To see all scheduled tasks created for every subscription, as well as
those created on the server level, go to Tools & Settings > Scheduled Tasks (Cron jobs).
You can sort the tasks by command, by subscription, or by schedule; the
latter is useful for troubleshooting issues with server load spiking at
certain times - this may be caused by a resource-intensive scheduled
task. For every task in the list you have the ability to change the
properties of the task (by clicking on the task’s name), activate it by
clicking the icon, deactivate it by clicking the
icon, or run the task immediately.
Note: In Plesk for Linux, by default, the scheduled tasks created by Plesk
users are executed in a chrooted shell, meaning that the file system
root is changed to the corresponding system user’s home directory.
This improves security, but limits the options of Plesk users. You
can change the shell to be used for scheduled tasks of all Plesk
users by going to Tools & Settings > Scheduled Tasks >
Settings. For more details about the shell settings, refer to
Scheduled tasks shell setting.
To create a scheduled task, go to Tools & Settings > Scheduled
Tasks > Add Task. First, you need to select the task type,
depending on your purpose:
-
Run a command. Specify the full path to the executable file to be
run. This includes binary files, shell scripts, and batch files. -
Fetch a URL. Specify the URL only, there is no need to type the
command, such as curl or wget. -
Run a PHP script. Specify the full path to the script, for
example:/tmp/script.php
.
Next, select how often the task will run, and set the desired time and
date. By default the time is in the server time zone; if you need to
select a different time zone, go to Tools & Settings > Scheduled
Tasks > Settings. You also have the ability to set a description
for the task, select the system user in whose security context the task
will run, and configure notifications.
Finally, before saving the task, you have the option to do a test run to
make sure that the task is configured correctly. Click Run Now and
wait for the task to finish. If the task finishes with an error, it will
also fail to work when executed by the scheduler, unless you find and
resolve the issue first.