How to Schedule a Task in Plesk for Linux?
Just so you know, Plesk has two different kinds of scheduled tasks:
job that is scheduled by a customer: This kind of job can be created by both administrators and customers. It is carried out on a system user’s behalf. You are not granted access to the filesystem beyond the website’s document root while performing such actions.
Task scheduled by an administrator: This kind of task can only be created by an administrator. The root user is the one who is responsible for its execution. You can write to the entire filesystem while doing such actions.
Steps to Schedule a Customer Scheduled Task from Plesk UI:
1. Log in to Plesk.
2. Navigate to Websites & Domains > example.com > Scheduled Tasks > Add Task.
3. Enter the full path to the script to be executed in the Command field.
4. Set the task execution time in the Run field (check an example here).
5. Click on OK to save changes.
Steps to Schedule an Administrator Scheduled Task from Plesk UI:
1. Log in to Plesk.
2. Navigate to Tools & Settings > Scheduled Tasks > Add Task.
3. Enter the full path to the script to be executed in the Command field.
4. Set the task execution time in the Run field.
5. Leave user as root in the System user field or select another system user to run the task:
6. Click on OK to save changes.
Steps to Create/Edit Scheduled Task from the Commands Line, SSH with a System User Account:
1. Log in to Plesk.
2. Let the customer connect to the server via SSH on the page Plesk > Subscriptions > example.com > Web Hosting.
3. Access and enable Access to the server over SSH.
4. Using a system user account connect to the server over SSH.
5. Run the below command to open crontab editor:
# crontab -e
Steps to Create/Edit the Scheduled Task from the Command Line, SSH with “root” Account:
1. Using SSH, connect to the server.
2. Execute the below command to open crontab editor for a specific user:
3. Replace johndoe with the your preferred username.
# crontab -e -u johnoe
4. Using cron file syntax, type in the cron task parameters. For example:
* * * * * /bin/echo "test" > /tmp/testfile
In this way, you can schedule a task in Plesk for Linux.