PDA

View Full Version : How to setup a cronjob



Fli
03-11-2013, 06:56 AM
Hi, if You need to setup an cronjob on linux hosting. It might be cpanel, linux shell, here is how the command to run url in cron can look like:

curl http://urlxyxyxy
wget -O http://urlxyxyxy /dev/null
wget -O – -q http:// (http://example.com/urltofetch.html)urlxyxyxy (http://urlxyxyxy/) >/dev/null 2>&1

(wget url alone would cause that website be downloaded into /home/user/ as a file! add -q to wget if you dont want to get email report of particular cronjob, q means quiet, >/dev/null 2>&1 will cause no email be sent too, also no file created)

Every 5 minutes cronjob to run some URL:

*/5 * * * * curl http://example.com/check/

kumkum
05-18-2022, 03:39 PM
If you are using cpanel then best and easy way to create cronjob is through cpanel:
> Login to cpanel >> Cronjob

You just have to use command to create cron job. You have to use below command to create cron job.
crontab –e

You can check complete steps to create cron job (https://hoststud.com/resources/how-to-add-crontab-and-cron-job-in-linux.256/).

myresellerhome
05-21-2022, 05:45 AM
Create a Cron Job
Follow these instructions to create a new cron job.

Step 1: Open Cron Jobs in cPanel by clicking Cron Jobs in the Advanced section.
Step 2 Scroll down until you reach the Add New Cron Job interface.
Step 3 Select an existing setting from the list of common settings. If you do this, all of the cron execution time fields will be filled automatically. Alternatively, you may define your unique runtime parameters in the following text boxes.
Step 4 Enter the command you want to execute in the cron job.
Step 5 To create a cron job, click the Add New Cron Job button.

HifiveHost
06-06-2022, 04:07 AM
Setup Cron Job step below have a look.
Step 1 − Open Cron Jobs by clicking Cron Jobs found in the Advanced section in cPanel.
Step 2 − Scroll down to see Add New Cron Job interface.
Step 3 − You can choose an existing setting from common settings. If you do that all the fields of cron execution time will automatically get filled.

Rex_M
09-06-2022, 11:14 AM
Hi, if You need to setup an cronjob on linux hosting. It might be cpanel, linux shell, here is how the command to run url in cron can look like:

curl http://urlxyxyxy
wget -O http://urlxyxyxy /dev/null
wget -O – -q http:// (http://example.com/urltofetch.html)urlxyxyxy (http://urlxyxyxy/) >/dev/null 2>&1

(wget url alone would cause that website be downloaded into /home/user/ as a file! add -q to wget if you dont want to get email report of particular cronjob, q means quiet, >/dev/null 2>&1 will cause no email be sent too, also no file created)

Every 5 minutes cronjob to run some URL:

*/5 * * * * curl http://example.com/check/

Hello Fli,

A cron job is a valuable process that allows you to automate several crucial web hosting tasks by specifying a command to run at scheduled intervals.

You can use the Cron Jobs interface to automate
specific commands or scripts on your site to
run at a particular time. For example, you could
set a cron job to remove temporary files every
week to free up space and back up your website.

Before setting up Cron Jobs, you must have good knowledge of Linux commands to avoid problems that can affect your website. Hence, you must check your script with your support team before creating a new cron job.

You can follow the below-given ways to set up the Cron Job feature in cPanel,

- Log in to your cPanel account, scroll down to the Advanced section and click the Cron Jobs icon.
- You will get the option to change a notification email address. It will send you an email notification every time the cron job runs.
- Your primary email is listed in the Cron Email section.
- Update Email box used to send notifications to different email addresses.
- Next, scroll to the Add New Cron Job section.
- Here, you can set the frequency at which you want the cron job to operate.
- Once you have set the cron job frequency, the next task is to input the command. Enter this in the Command field.
- Click the Add New Cron Job button when finished. A confirmation pop-up will appear to ensure that the cron job has been added.
- To check the created Cron Job, navigate to the Current Cron Jobs section at the bottom of the page. The Cron Job will appear at Current Cron Jobs.

Lastly, you will be notified every time via email when the script runs on its provided time.

I hope the above-given ways help you set up your new Cron Job task.

-------------------
Regards,
Rex M