Create cron job in cPanel
Added: 10.03.2014 23:26:29 Last updated: 18.01.2017 15:50:23
This guide details how to proceed to create a cron job to run script/commandos automatically at certain time intervals.
Click on the icon for "Cron jobs" as shown in the screenshot below:
- Every time a cron job is run, the result is sent to an email address. We type the email address we want the results to be sent to.
- Click "Update email" if you make changes in which email it should be sent to.
- In this drop down menu you can choose between the most common settings for when the script should run. Here we have chosen that it shall be run every day, at midnight.
- You can also decide yourself exactly when you want the job to be run:
Minute: Choose which minute of the hour the job should run. We choose 0 to run skript.php the first minute of the hour.
Hour: Choose which hour of the day the job should run. We choose 0 to run skript.php the first hour of the day (midnight).
Day: Choose which day of the month the job should run. We choose * to run skript.php every day.
Month: Choose which month of the year the job should run. We choose * to run skript.php every month.
Weekday: Choose which day of the week the job should run. We choose * to run skript.php every weekday.
- We have to specify which script we want to run (including full path from root). On our servers this will be "php -q /home/"your username"/public_html/skript.php" where we have saved skript.php in the root of the folder "public_html". You can of course place the script that should be run in a sub folder if you want
- Click "Add Cron job".
- Here you will get a confirmation that your cron job has been added.
- If you need to make changes in the script you want to run, or make other changes, click "Edit".
- If you want to delete the job, click "Delete".
We have not set up a cron job to run the file "skript.php" for our account, once a day.
You can create as many cron jobs as you want, but please pay attention to the fact that cron jobs in certain settings can use a lot of resources in a server.