Creating cron jobs in Plesk
Create Plesk cron jobs via Tools & Settings > Scheduled Tasks. Choose task type (command, PHP, URL), set schedule, and save. Automate tasks!
This article will guide you through the process of creating scheduled tasks, often referred to as cron jobs, within your Plesk hosting environment. Cron jobs allow you to automate commands or scripts to run at specific times or intervals. This can be useful for tasks such as:
- Running website backups
- Executing maintenance scripts
- Sending automated emails
- Updating website content
Let’s walk through the steps:
- Log in to your Plesk Panel. You can usually access your Plesk panel by navigating to
https://yourdomain.com:8443or a similar URL provided by Liquid Web. Use your Plesk username and password to log in. - Navigate to “Tools & Settings”. In the left-hand navigation menu, find and click on Tools & Settings.
- Under “Tools & Resources”, click on “Scheduled Tasks (Cron Jobs)”. You’ll find this option within the Tools & Resources group of tools.
- Click “Add Task”. This button is typically located on the top of the Scheduled Tasks page.
- Configure the Task Details: You will now see a form to configure your scheduled task. Here’s a breakdown of the options:
- Task type: Choose the type of task you want to schedule. Your options may include:
- Run a Command: Executes a system command. This is commonly used for running scripts (e.g., PHP, Python).
- Command: (If you selected ” Run a Command” as the task type) Enter the full path to the command or script you want to execute, along with any necessary parameters. For example, to run a PHP script named
backup.phplocated in thehttpdocs/scriptsdirectory, you might enter:/opt/plesk/php/*/bin/php /var/www/vhosts/yourdomain.com/httpdocs/scripts/backup.phpNote: The exact path to the PHP interpreter (/opt/plesk/php/*/bin/php) might vary slightly depending on your Plesk version and server configuration. If you are unsure, you can often find the correct path in your Plesk PHP settings or by contacting Liquid Web support.
- Command: (If you selected ” Run a Command” as the task type) Enter the full path to the command or script you want to execute, along with any necessary parameters. For example, to run a PHP script named
- Fetch a URL: Accesses a specified web address (URL).
- URL: (If you selected “Fetch a URL” as the task type) Enter the full URL you want the system to access.
- Run a PHP script: Executes a specific PHP script located on your hosting account.
- PHP script path: (If you selected “Run a PHP script” as the task type) Add the path to the PHP script that you would like the schedule the cron to run.
/tmp/script.phpas an example. You also have the option to add any additional arguments that you want.
- PHP script path: (If you selected “Run a PHP script” as the task type) Add the path to the PHP script that you would like the schedule the cron to run.
- Run a Command: Executes a system command. This is commonly used for running scripts (e.g., PHP, Python).
- Run: This section allows you to define the schedule for your task. You can choose from predefined options or create a custom schedule using cron syntax:
- Predefined: You can select options like “Daily”, “Weekly”, “Monthly”, or specify a time of day.
- Cron style: This gives you more granular control over the schedule using standard cron syntax. For example (More about the Cron Style format can be found here):
- To run a script every hour:
0 * * * * - To run a script daily at 3:00 AM:
0 3 * * * - To run a script every Monday at 6:00 PM:
0 18 * * 1
- To run a script every hour:
- Description: You can add a brief description of the task for your reference.
- Run this task: You can choose the user under which the task will be executed. It’s generally recommended to run tasks under the “system user” of the associated subscription.
- Notify on task completion: You can optionally provide an email address to receive notifications when the task is completed (or fails).
- Task type: Choose the type of task you want to schedule. Your options may include:
- Click “OK” to save your scheduled task.
Your newly created cron job will now appear in the list of scheduled tasks and will run according to the schedule you defined. You can edit or remove tasks from this list as needed.
If you encounter any issues or have specific scheduling requirements, please don’t hesitate to contact our Liquid Web support team for assistance.