Site5 - Built For Designers & Developers MENU
Home  ›  Control Panels  ›  How to setup and manage Cron Jobs

How to setup and manage Cron Jobs

15 Comments

Cron Jobs allow you to automate certain commands or scripts on your site. You can set a command or script to run at a specific time every day, week, etc. For example, you could set a cron job to delete temporary files every week so that your disk space is not being used up by those files.

If you are using one of our shared services, please keep in mind that cron jobs should not run in less than 15 minute intervals. For more information, please read our resource usage police located here.


 

Create and manage cron jobs within SiteAdmin

This demo assumes you’ve already logged in to SiteAdmin

1) Click the Programming Center link from the left-hand menu, then click the Cron Jobs link or the Cron Jobs icon from within your main screen.

2) Now you have to define exactly when and how often you want the cron job to run. This is made easier by using one of the pre-defined or common settings

3) Next, enter the command of the script you want to run, including the path (from root)

 

Note: You will need to enter the prefix path for the binary you wish to use to run your script. For example, if you wanted to run a PHP script using the default version of PHP, you would enter the following before your path…

“/usr/bin/php ”

If you wanted to use a different version of PHP (e.g. 5.2,), make sure you use the correct binary (“/usr/local/php52/bin/php”) for your needed version. You can find most binary paths here.

Remember to add a space between the binary and the path. For example, below you see there is a space between ‘php’ and ‘/home’…

“/usr/bin/php /home/username/script.php”

4) If you do not wish to receive email notifications every time the cron job runs, you can disable it by checking the Disable Email Notification option

5) Click Add new Cron Job 

That’s it! You now have a cron job setup and running. If you need to set a custom time that is not included in the common settings drop-down, you can click the Show Advanced Options button.

 

This is the end of the tutorial. You now know how to setup cron jobs in SiteAdmin.


 

Create and modify cron jobs within cPanel

This demo assumes you’ve already logged in to cPanel

If you are using one of our shared services, please keep in mind that cron jobs should not run in less than 15 minute intervals. For more information, please read our resource usage police located here.

Now let’s learn how to setup a cron job

1) Click the Cron Jobs icon

2) Enter the email address where you want the cron job results sent after each time it runs

3) Now you have to define exactly when and how often you want the cron job to run. This is made easier by using one of the pre-defined or common settings

Notice that by choosing a common setting, all fields are filled in automatically. This also helps you understand what each field means

4) Let’s choose Once a week

5) Next, enter the command of the script you want to run, including the path (from root)

 

Note: Remember to prefix the path with the binary you wish to use to run your script. For example, if you wanted to run a PHP script using the default version of PHP, you would enter the following before your path…

“/usr/bin/php ”

If you wanted to use a different version of PHP (e.g. 5.2,), make sure you use the correct binary (“/usr/local/php52/bin/php”) for your needed version. You can find most binary paths here.

Remember to add a space between the binary and the path. In the example below note the space between ‘php’ and ‘/home’.

“/usr/bin/php /home/username/script.php”

6) When ready, click Add New Cron Job

That’s it! The cron job has been set as you can see here. You can create additional cron jobs, and edit or delete existing ones

This is the end of the tutorial. You now know how to setup cron jobs in cPanel

Still have a question? Or need help?
If you need technical support with your account, please email us or chat live with a representative.

15 Comments

  • cron jobs demo images are very small and distort when I zoom in …so they are of no help at all.

  • Hi Jim,

    I am sorry to hear that. The zoom-in feature works normally for me, in Firefox. Have you tried this in another browser?

  • Works good no distortion in Chrome as well.

  • When scheduling crons, I learned that they run on UTC time. Which means setting a cron for “midnight”, will run at 8am in EST. So to get a cron to run at midnight EST, set it for “4 AM”.

    (This should be explained in the cron tool.)

    • Hello Daniel,

      The cron schedule actually runs on the timezone the server is in. A New York-based server is set to Eastern time, and would match up with your time zone.

      • I mentioned this because ran a cron at “midnight” on my server (Dallas, cloud web), and it ran at 8am EST.

        • Hi Daniel,

          Very strange, as even if running at local Dallas time, it would not be 8am Eastern. Can I ask you to open a ticket with our support team on this, via BackStage, so we can confirm the timezone settings on the server?

          • Tech support confirmed that the Dallas server specifically is running on UTC time.

  • Will do. Sorry my post might confuse this page!

  • Using “crontab -e” via PuTTY to set up a cron job doesn’t work. I entered a line that has worked on other web servers, but doesn’t work on Site5.

    • Hi Jim,

      crontab -e should work, yes – keep in mind that while your cron entry may work elsewhere, every host sets up their servers a little differently, requiring some changes to the cron. If your cron is not running properly, I would suggest you contact our support team so we can take a look at why :)

  • is it compulsory to add ” on command line.?

    • No, the quotation marks are not necessary, and are included here just to indicate the actual commands.

  • For SiteAdmin, is it possible to adjust timing in textbox, e.g. running cron hourly from 2am to 7am on every Sunday?

    • This is possible, though a cron schedule this complex would need to be created manually, rather than use the options in Siteadmin. That would look something like this:

      * 2-7 * * 0 $command

      If you like, our team can help you set this up. Just contact support via a chat or a ticket in Backstage, and we’d be happy to get this working for you.

Money Back Guarantees