Create a Cron Job in cPanel – Cron Job Tutorial for Dummies

Cron Job in cPanel

This guide is meant for anyone who wants to create a cron job and for all those who has never ever created a cron job in their life through cPanel.

First of all, what is a cron job ? This is Wikipedia‘s explanation:

Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration, though its general-purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.

Cron is available on Unix, Linux and Mac servers. Windows servers use a Scheduled Task to execute commands.

All the cron jobs tutorials just concentrates on the steps on scheduling a cron job, but most of the the users don’t know anything about Unix/Linux commands or even aabout command-line. So they make mistakes in adding the command to the Command textbox of the cPanel.

Cron Command Text Box of cPanel

PHP is one of the most popular server-side programming language, so I will concentrate on adding a PHP script as a cron job. In addition to that you will be provided with a working(and tested) PHP code to find the path to be mentioned in the cron command textbox.

Open your text editor and paste the following:

Now follow the steps mentioned below to get running…

  1. Save it as path.php
  2. Upload it to the directory where your php file meant for the cron job is located
  3. Now run the file in browser
  4. Copy the output to your text editor

The output will be like

/home/USERNAME/public_html/DIRNAME
or
/home2/USERNAME/public_html/DIRNAME

Now append the filename of the script that you want to run to the output. The final line will now look like /home/USERNAME/public_html/DIRNAME/FILENAME

where

USERNAME - Your cPanel Username

DIRNAME - the directory name where the file resides

FILENAME - the file name of the file that you want setup as a cron job

Now launch Cron Jobs section of your cPanel. It will look like this:

Add a new Cron Job

In the screenshot above I’ve selected daily as my interval and entered the following line of text into the Command textbox.

php /home/USERNAME/public_html/crons/my-cron.php

where

crons - the directory where my php file resides

my-cron.php - the php file to be setup as a cron job

Now click the Add New Cron Job and your are done !

Voila! You’ve scheduled a cron job !

The only two WordPress SMTP Plugins that you ever need

job hunting

If you want to implement e-mail sending functionality in your WordPress site without any reliability issues or without the nuisance of mails going to the user’s Spam/Junk folder, it’s recommended to use SMTP instead of the default WP mailing function(which uses the default PHP mail function) .

I would recommend you to use SMTP even if you are only having a simple contact form and you love dependability.

Here are the two most recommended plugins that I’ve used and in the order of my preference:

WP Mail SMTP

This plugin reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page that allows you to specify various options.

You can set the following options:

  • Specify the from name and email address for outgoing email.
  • Choose to send mail by SMTP or PHP’s mail() function.
  • Specify an SMTP host (defaults to localhost).
  • Specify an SMTP port (defaults to 25).
  • Choose SSL / TLS encryption (not the same as STARTTLS).
  • Choose to use SMTP authentication or not (defaults to not).
  • Specify an SMTP username and password.

Configure SMTP

Use this plugin to customize the SMTP mailing system used by default by WordPress to handle outgoing e-mails. It offers you the ability to specify:

  • SMTP host name
  • SMTP port number
  • If SMTPAuth (authentication) should be used.
  • SMTP username
  • SMTP password
  • If the SMTP connection needs to occur over ssl or tls
Regardless of whether SMTP is enabled, the plugin provides you the ability to define the name and e-mail of the ‘From:’ field for all outgoing e-mails.

Chanakya Quotes worth learning

Here are some of the most popular quotes from Chanakya.

“A person should not be too honest. Straight trees are cut first and Honest people are screwed first.”

“Even if a snake is not poisonous, it should pretend to be venomous.”

“The biggest guru-mantra is: Never share your secrets with anybody! It will destroy you.”

“There is some self-interest behind every friendship. There is no Friendship without self-interests. This is a bitter truth.”

“Before you start some work, always ask yourself three questions – Why am I doing it, What the results might be and Will I be successful. Only when you think deeply and find satisfactory answers to these questions, go ahead.”

“As soon as the fear approaches near, attack and destroy it.”

“Once you start working on something, don’t be afraid of failure and don’t abandon it. People who work sincerely are the happiest.”

“The fragrance of flowers spreads only in the direction of the wind. But the goodness of a person spreads in all direction.”

“Whores don’t live in company of poor men, citizens never support a weak company and birds don’t build nests on a tree that doesn’t bear fruits.”

“God is not present in idols. Your feelings are your god. The soul is your temple.”

“A man is great by deeds, not by birth.”

“Never make friends with people who are above or below you in status. Such friendships will never give you any happiness.”

“Treat your kid like a darling for the first five years. For the next five years, scold them. By the time they turn sixteen, treat them like a friend. Your grown up children are your best friends.”

“Books are as useful to a stupid person as a mirror is useful to a blind person.”

“Education is the best friend. An educated person is respected everywhere. Education beats the beauty and the youth.”

Image Courtesy

Pragmatic Programmer Tips Sheet – Noteworthy ones that no Developer or Consultant can push aside

Larry Wall

As a tech consultant to some of the IT companies, I’ve always felt that the companies(and employees) could have minimized or eliminated many of their headaches if they had implemented some of the ideas given below…

Here are some straight lifts from The Pragmatic Programmer

Provide Options, Don’t Make Lame Excuses
Instead of excuses, provide options. Don’t say it can’t be done; explain what can be done.

Be a Catalyst for Change
You can’t force change on people. Instead, show them how the future might be and help them participate in creating it.

Make Quality a Requirements Issue
Involve your clients in determining the project’s real quality requirements.

Critically Analyze What You Read and Hear
Don’t be swayed by vendors, media hype, or dogma. Analyze information in terms of you and your project.

Program Close to the Problem Domain
Design and code in your client’s language.

Always Use Source Code Control
Source code control is a time machine for your work—you can go back.

Test Your Software, or Your Clients Will
Test ruthlessly. Don’t make your clients find bugs for you.

Gently Exceed Your Users’ Expectations
Come to understand your users’ expectations, then deliver just that little bit more.

Work with the Client to Think Like a Client
It’s the best way to gain insight into how the system will really be used.

Why it’s good to keep your mouth shut sometimes ?

A little bird was flying South for the winter. It was so cold, the bird froze and fell to the ground in a large field. While it was lying there, a cow came by and dropped some dung on it. As the frozen bird lay there in the pile of dung, it began to realize how warm it was. The dung was actually thawing him out! He lay there all warm and happy and soon began to sing for joy.

A passing cat heard the bird singing and came to investigate. Following the sound, the cat discovered the bird under the pile of cow dung and promptly dug him out and ate him!

Moral of the story: When you’re in deep shit, keep your mouth shut!

Why you should think Local before going Global ?

There were three tailors doing business on Tailor’s Street, in a far, far away city.

One of them, trying to get more customers to his shop, painted a big sign outside,
stating:

Here is the best tailor in town.

Clients crowded to his door for the next two weeks. Seeing that, the second tailor
down the street, painted another sign himself, stating:

Here is the best tailor in the world! 

So, for the next two weeks, all the clients moved from the first shop to his, making
him busy and happy…

Seeing all his neighbors drifting from one of his competitors to the other, the third
tailor wrote his own sign, getting all the customers only to himself further on:

Here is the best tailor on this street!

 

Moral of the story: You should be having self awareness (about your business) and also think local first!