Quantcast How to setup a cron job in cPanel? - digitalFAQ Forum
  #1  
08-25-2013, 08:48 PM
Brent Brent is offline
Premium Member
 
Join Date: Jul 2012
Location: Raleigh, NC
Posts: 231
Thanks: 3
Thanked 13 Times in 12 Posts
This demo assumes you've already logged in to cPanel. 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



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.

3) Let's choose Once a week



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



5) 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.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
11-12-2013, 07:47 AM
kpmedia's Avatar
kpmedia kpmedia is offline
Site Staff | Web Hosting, Photo
 
Join Date: Feb 2004
Posts: 4,096
Thanks: 205
Thanked 321 Times in 306 Posts
Additional Tips:

A lot of CMS plugins -- so-called "premium" WordPress plugins especially -- give bad advice when it comes to manual cron jobs. I've seen some insist the cron run every 1 or 2 minutes -- or even a seemingly reasonable (but not really!) 5 minutes.

On a shared server, this is unreasonable. It causes far too much server load, and is adequate reason for suspension. You'll need a VPS or dedicated server for that much use. Every 30 or 60 minutes is reasonable. May 15 or 30, but even then, not really.

Pick your cron job times carefully!


Need a good web host? — Read our 2017 Review of the Best Web Hosts
Quite often, problems with web sites are caused by having a rotten web host. Worse yet, many hosts try to blame you (the customer) for the problems! So dump that lousy company. Say goodbye to slow sites, unresponsive support techs, and downtime. Find yourself a new host today. Whether you need shared, reseller, VPS, semi-dedicated, cloud, or dedicated hosting, something on our list should be a good upgrade for you.


- Did my advice help you? Then become a Premium Member and support this site.
- Please Like Us on Facebook | Follow Us on Twitter

- Need a good web host? Ask me for help! Get the shared, VPS, semi-dedicated, cloud, or reseller you need.
Reply With Quote
  #3  
07-19-2016, 09:41 AM
MikeDVB MikeDVB is offline
Free Member
 
Join Date: Jul 2016
Location: Central, Indiana, USA
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MikeDVB Send a message via Skype™ to MikeDVB
Quote:
Originally Posted by kpmedia View Post
Additional Tips:

A lot of CMS plugins -- so-called "premium" WordPress plugins especially -- give bad advice when it comes to manual cron jobs. I've seen some insist the cron run every 1 or 2 minutes -- or even a seemingly reasonable (but not really!) 5 minutes.

On a shared server, this is unreasonable. It causes far too much server load, and is adequate reason for suspension. You'll need a VPS or dedicated server for that much use. Every 30 or 60 minutes is reasonable. May 15 or 30, but even then, not really.

Pick your cron job times carefully!


Need a good web host? — Read our 2017 Review of the Best Web Hosts
Quite often, problems with web sites are caused by having a rotten web host. Worse yet, many hosts try to blame you (the customer) for the problems! So dump that lousy company. Say goodbye to slow sites, unresponsive support techs, and downtime. Find yourself a new host today. Whether you need shared, reseller, VPS, semi-dedicated, cloud, or dedicated hosting, something on our list should be a good upgrade for you.
It's not really so important how often the cron runs as much as how resource intensive the cron is. If the cron is a heavy-hitter running it every minute is obviously going to be a bad idea.

If the cron task being executed itself is light-weight running it every minute shouldn't be a problem at all. I know personally on my sites I have several 1-minute crons as every time it fires off it uses so little resources when there's nothing for it to do that it's not a problem.

When it comes to the command - one thing to keep in mind is that it's always going to be best to run the file locally than to execute it through the web server.

Executing a PHP Script locally:
Code:
php -q /home/youraccountname/public_html/your-script-cron-folder/cron-file.php > /dev/null
Executing a PHP Script through the web server:
Code:
wget -O /dev/null http://www.yourdomainname.com/your-script-cron-folder/cron-file.php
At the end of the day the result of both methods is the same - the script is executed and performs its tasks. The difference is that the first simply invokes the PHP interpreter to run the file without involving the web server, HTTP connections, headers, etc... The second actually makes a request to the web server invoking all of the aforementioned overhead.

Furthermore by invoking them locally you can many times place the cron script outside of public view so that it cannot be activated by third parties/maliciously. It is up to your software to support this though.

One last thing - if you decide to use WGET make sure to send the output somewhere like /dev/null otherwise you're going to very quickly find your account home directory filling up with the saved output from your cron job.

Hopefully this helps .

Michael Denney - MDDHosting LLC
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to setup domain redirects in cPanel Brent cPanel 0 08-25-2013 08:46 PM
How to setup Hotlink protection in cPanel Brent cPanel 0 08-25-2013 08:43 PM
How to setup desktop shortcuts for cPanel Brent cPanel 0 08-25-2013 08:38 PM
How to setup email filters in cPanel Brent cPanel 0 08-25-2013 08:23 PM
How to setup an auto-responder in cPanel Brent cPanel 0 08-25-2013 08:08 PM

Thread Tools



 
All times are GMT -5. The time now is 02:27 PM  —  vBulletin Copyright Jelsoft Enterprises Ltd