2. Set your Auction Cron Job

In This Article
  • Why & How to set Server CRON Jobs
  • Cron Jobs with URL
  • How to add cron job to hosting cpanel
  • Example of different types hosting cpanel
  • How to set cron job on WP Engine hosting
  • Easycron

Why & How to set Server CRON Jobs

Let us first highlight why exactly would you need server cron jobs. Every auction has its own end date and time. When we were initially designing this software, there was a need to run a background job which can check particular events and then trigger specific actions. Let me give you few examples:

  • Checking start time for Future Auctions and if there time is due then make those auctions live.
  • Checking end time for Live Auctions and if there time is due then expire those auctions.
    • Change status of auction products from live to expired
    • Send winning email to winner
    • Send winning SMS to winner
    • Perform Automatic Debit of winning amount from their credit card
  • Send Emails & SMS for specific actions
    • Payment Reminder 
    • Bid and OutBid Notifications
    • Winning Notifications

Since your website can perform these above actions properly and without any human interventions, you as admin have to set below parameters inside your hosting server and then our plugin will ensure that events, emails, SMS associated with auction products will be processed and sent on timely basis.

Cron Jobs with URL

1) Auction Status - This cron job is responsible for checking auction status (both future to live and live to expired) and        sending winning emails to winner. Below is example url for this cron job.

wget -q -O - http://example.com/?ua-auction-cron=process-auction >/dev/null 2>&1

  • Recommendation: We recommend you to set it to every minute.

2) Ending Soon Email - This cron job is responsible to send "Ending Soon" email based on the hours set inside "Ultimate Auction - Ending Soon Notification" email (under WooCommerce > Settings > Emails).Below is example url for this cron job.

wget -q -O - http://example.com/?ua-auction-cron=ending-soon-email >/dev/null 2>&1

  • Recommendation: We recommend you to set it to every hour.

3) Payment Reminder - This cron job is responsible to send "Payment Reminder" email based on the hours set inside "Ultimate Auction - Payment Reminder" email (under WooCommerce > Settings > Emails).Below is example url for this cron job.

wget -q -O - http://example.com/?ua-auction-cron=payment-reminder-email >/dev/null 2>&1

  • Recommendation: We recommend you to set it to every hour.

3) Automatic Relist - This cron job is responsible for relisting expired auction products which are due to be relisted.Below is example url for this cron job.

wget -q -O - http://example.com/?ua-auction-cron=auto-relist >/dev/null 2>&1

  • Recommendation: We recommend you to set it to every hour.

So, admin can use different cron job url same as shown above.Make sure to replace your url with example.com.Different command used in cron job url shown above.Below is description of each command.

  • wget - command is used to hitting a PHP script can be achieved by using cron. Wget's -­q or –quiet option turns off wget’s output which is exactly what we want since we do not intend to generate content but only hit the PHP script.
  • /dev/null - The purpose of this is to suppress any output from the command itself.accepts and discards all input, produces no output (always returns an end-of-file indication on a read).
  • 2>&1 - ">"  redirects output to a file, overwriting the file. ">>" redirects output to a file appending the redirected output at the end. Standard output is represented in bash with number 1 and standard error is represented with number 2. They are separate, so the user can redirect them to different files. 2>&1 redirects the stand ard error to the standard output so they appear together and can be jointly redirected to a file. (Writing just 2>1 would redirect the standard error to a file called "1", not to standard output.)

How to add cron job to hosting cpanel

So let's understand step by step how to add create cron job in hosting control panel.

Step 1 - First login to the hosting control panel which you are using.

Step 2 - After logging in, there will be a option for create cron job in cpanel. In most of cpanel this is in the Advanced section at the bottom. 

Step 3 - When click button for cron job, the form will open for url and common setting.

Step 4 -  Select option from dropdown of common setting. It is commonly used time and date interval.We have given time recommendations for different cron jobs above.This setting is same in all hosting cpanels. let's understand different options of this dropdown.

  • Minute – This menu allows you to select the number of minutes between running the cron job, or the minute each hour on which you wish to run the cron job.
  • Hour – This menu allows you to select the number of hours between running the cron job, or the hour each day on which you wish to run the cron job.
  • Day – This menu allows you to select the number of days between running the cron job, or the day of the month on which you wish to run the cron job.
  • Month – This menu allows you to select the number of months between running the cron job, or the month of the year in which you wish to run the cron job.
  • Weekday – This menu allows you to select the day(s) of the week on which you wish to run the cron job.

Step 5 - Add cron job url which you want to create it.Four cron job url are displayed above.Add one of them and submit it.Path to curl can be “/usr/local/bin/curl”, “/usr/bin/curl” or set “wget -q -O –“ etc. Best way to make sure you have exact path to curl is to contact your hosting support (and ask them to help you setup cronjobs, afterall they're there to help you with things like these).

Step 6 - To check if cronjob works you can create one sample auction, which ends in minute, or two and then wait for auction finished email notification.

Example of different types hosting cpanel

  • HostGator - First login to hostgator control panel.After that go to advanced Settings which is appears in cpanel dashboard.There you will see the cron jobs option as per below image.Click on that option.

    Now, first do common settings as explained above and then add cron job URL as per below image.In the example, we have added the URL for auction status cron job.Admin can add any url of four cron job.

  • Bluehost - First login to bluehost control panel.After that go to advanced Settings which is appears in cpanel dashboard.There you will see the cron jobs option as per below image.Click on that option.

    Select common setting options and add cron job URL as per below image.

  • Cloudways - Login to cloudways dashboard. Click cron job management option which is appear in left sidebar.In cron job management menu, there is a option for add new cron job.Below form will be open after clicking "Add new cron job" button.Select time option for cron job from dropdown, add cron job URL and submit it.
  • Godaddy - For this setting we provide below document link which is helpful. 
    https://in.godaddy.com/help/create-cron-jobs-16086

How to set cron job on WP Engine hosting

Cron is a technology to run scheduled tasks on web server. WordPress comes with its own built-in cron that allows it to perform scheduled tasks such as checking for updates, publishing schedule posts, etc. Plugins can also use it to perform tasks specified by you.

Step 1 - Go to wordpress dashboard -> Add new plugin. Here add WP Crontrol plugin , install and active it. WP Control plugin makes it easy to add your own cron jobs to WordPress. 

Step 2 - Go to Tools -> Cron events. There you will see a list of all cron events scheduled to run on your site using the WordPress cron system.

Step 3 - For add new cron job go to "Add Cron Event" tab. Clicking on this tab will open the form as follows.

Hook Name : First admin need to provide a hook name for your cron event. Hook names cannot have spaces or special characters.

Arguments : If the function you want to execute requires arguments, then you can provide those arguments. This setting is optional.

Next Run : Admin need to tell WordPress when to run the cron next time. You can enter ‘now’ which will trigger cron immediately, ‘tomorrow’, ‘+2 days’, or ’25-02-2020 12:34:00′.

Recurrence :  Admin need to select a schedule. You can select hourly, twice daily, daily, or once a week. You can also make it non-repeating event.

Step 4 - Once you are done, click on the "Add Event" button to save your changes. You will notice that your cron event will now appear in the events list.

Step 5 - Now, admin need to create function which define that what to do when this event is triggered. In below function "wpb_custom_cron" is a hook name which admin enter in above form. Admin can add their email address instead of "you@example.com". This function simply sends a test email to you when the cron runs.

add_action( 'wpb_custom_cron', 'wpb_custom_cron_func' );
function wpb_custom_cron_func() {
  wp_mail( 'you@example.com', 'Automatic email', 'Automatic scheduled email from WordPress to test cron');
}

If you have any query regarding wp-cron then please check event scheduling document.

Easycron

If your hosting company does not support one minute cronjobs. we suggest that you move your website to more serious hosting company or use service like EasyCron. The steps to set the EasyCron are shown below.

Step 1 - Open your cron job dashboard. Register or login to dashboard.

Step 2 - Firstly, click on " Cron Job" button.

Step 3 - In field "URL to call", enter following URLs respectively for each cron job:

  http://www.example.com/?auction-cron=check (cron job run "every minute")

  http://www.example.com/?auction-cron=mails (cron job run "once a day")

  http://www.example.com/?auction-cron=relist (cron job run "every hour")

  http://www.example.com/?auction-cron=closing-soon-emails (cron job run "every 30 mins")

 ( Note: Make sure to replace your url with example.com).

Step 3 - If necessary, finish the other optional settings.

Step 4 - Click "Create Cron Job" button. You're done! EasyCron will trigger your Auctions' cron job script dutifully according to your time setting.

We cannot use WordPress cronjobs because they are not reliable and depend on visitor accessing your website. In order to have reliable auctions you need real cronjobs. Our plugin is meant to be used as ecommerce solution which will earn money. so we suggest you to invest in proper hosting (which at least supports one minute cronjobs).

Still need help? Send Your Query Send Your Query