2. Set your Auction Cron Job

In This Article

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 that can check particular events and then trigger specific actions. Let me give you few examples:

  • Checking start time for Future Auctions and if their time is due then make those auctions live.
  • Checking end time for Live Auctions and if their time is due then expire those auctions.
    • Change status of auction products from live to expired
    • Send winning email to the winner
    • Send winning SMS to the 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 the 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 a 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 the winner. Below is an example URL for this cron job.

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

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

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

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

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

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

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

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

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

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

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

5) Ending soon SMS -  This cron job is responsible to send an "Ending Soon" SMS based on the hours set inside the "Twillio Ending soon SMS" (under Twillio Sms Notification addon)

wget -q -O - https://example.com/?ua-auction-cron=ending-soon-sms >/dev/null 2>&1
  • Recommendation: We recommend you set it to every hour.

So, the admin can use a 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 a 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 redirect the standard 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.)

Please review the below video for cronjob URLs. This video will cover how to set the Cronjob URLs on the cPanel and set up the hooks for the Cronjob using the wp-crontrol plugin.

How to add cron job to hosting cpanel

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

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

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

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

Step 4 -  Select the option from the dropdown of the common setting. It is commonly used time and date interval. We have given time recommendations for different cron jobs above. This setting is the same in all hosting cpanels. let's understand the 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 URLs 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. The best way to make sure you have the exact path to curl is to contact your hosting support (and ask them to help you set up cronjobs, after all, 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 a minute, or two and then wait for the 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 the below image. Click on that option.

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

  • 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 the below image. Click on that option.

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

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

Easycron

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

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

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

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

  https://example.com/?ua-auction-cron=process-auction (cron job run "every minute")

  https://example.com/?ua-auction-cron=auto-relist (cron job run "every hour")

  https://example.com/?ua-auction-cron=payment-reminder-email (cron job run "every hour")

  https://example.com/?ua-auction-cron=ending-soon-email (cron job run "every hour")

  https://example.com/?ua-auction-cron=ending-soon-sms (cron job run "every hour")

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

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

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

How to set cronjob on cron control plugin

Step 1 - Go to WordPress dashboard -> Add new plugin. Here add WP Crontrol plugin, install and active it. WP Crontrol 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 - To add a new cron job go to the "Add Cron Event" tab. Clicking on this tab will open the form as follows.
Hook Name: First admin needs to provide a hook name for your cron event. Hook names cannot have spaces or special characters. Admin can use the listed hooks as required.
  • scheduled_process_auction - This hook is responsible for checking auction status (both future to live and live to expired) and sending winning emails to the winner.
  • scheduled_ending_soon_email - This hook is responsible to send an "Ending Soon" email based on the hours set inside the "Ultimate Auction - Ending Soon Notification" email (under WooCommerce > Settings > Emails).
  • scheduled_auto_relist - This hook is responsible to send a "relist auction" email for relisting expired auction products which are due to be relisted.
  • scheduled_payment_reminder_email - This hook is responsible to send "Payment Reminder" email based on the hours set inside "Ultimate Auction - Payment Reminder" email (under WooCommerce > Settings > Emails).
  • scheduled_ending_soon_sms - This hook is responsible to send an "Ending Soon" SMS based on the hours set inside the "Twillio Ending soon SMS"  (under Twillio Sms Notification addon)
Arguments: If the function you want to execute requires arguments, then you can provide those arguments. This setting is optional.
Next Run: Admin needs 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 needs to select a schedule. You can select hourly, twice daily, daily, or once a week. You can also make it a 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.

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

Still need help? Send Your Query Send Your Query