Plesk for Linux
kb: how-to
ABT: Group B
Applicable to:
- Plesk for Linux
Question
How to schedule a task in Plesk for Linux?
Answer
There are two types of scheduled tasks in Plesk:
- Customer scheduled tasks. This type of tasks can be created by both Customers and Administrators. They are executed on behalf of a system user. Such tasks do not provide access to the filesystem outside of the document root of the web site.
- Administrator scheduled asks. This type of tasks can be created by Administrators only. They are executed on behalf of the root user. Such tasks provide write access to the whole filesystem.
Click on a section to expand
How to schedule a Customer scheduled task from Plesk UI:
How to schedule an Administrator scheduled task from Plesk UI:
- Log in to Plesk
- Go to Tools & Settings > Scheduled Tasks > Add Task.
- In the Command field, put the full path to the script to be executed.
- In the Run field, set the the task execution time.
- In the System user field, leave user as root or choose another system user to run the task:
- Click OK to save changes.
How to create/edit scheduled task from the command line, SSH with a system user account:
How to create/edit the scheduled task from the command line, SSH with "root" account:
- Connect to the server via SSH
- Run the following command to open crontab editor for a specific user:
Replace johndoe with the desired username.# crontab -e -u johnoe
-
Type in the cron task parameters, using cron file syntax. For example:
* * * * * /bin/echo "test" > /tmp/testfile
Additional information
Plesk documentation: Scheduling tasks
To do it through CLI (Command line interface), the crontab system utility can be used: crontab(1) — Linux manual page
Comments
3 comments
Hi, I need to run this cron task: php -q /var/www/vhosts/domain/httpdocs/folder/cron.php >/dev/null 2>&1
These are the literal instructions from the service provider:
How do I enter this, as "Run as command" results in error:
Also, what's the best user to select for the job?:
Thanks!
Hello @Mario,
Thank you for your question.
As I can see the issue was resolved in the scope of the ticket and it was suggested to run the script with any installed Plesk PHP:
I want to report a bug in Scheduled task feature and how to reproduce.
1. Create a scheduled task with the following command:
(note the typo, comma instead of dot).
2. Save.
It will show a "parse error" but it will save.
3. Now you cannot open again Scheduled Task because you will face "parse error". Even from Tools & Settings > Scheduled Task you cannot edit the wrong command due to same error. Any user without SSH access is then stuck here.
Please sign in to leave a comment.