Currently set to No Index

Using cPanel to Setup Cron Jobs

3 minutes 1 comments
Avatar
Dmitry
Web Hosting Geek

The “cron job” is one of the basic programming tools that remind you that you can get a lot of function out of learning just a little code.  A “cron job” is simply a command that you instruct your server to perform at regular intervals.  It can literally be any command that you can run normally.

You have the power!

Not only are the advantages of this obvious, but once you realize the power you can get from this in just a few commands, much of what you use control panels for may start to seem frivolous.  You can, for example, in just a single command backup an entire directory once a week and email it to yourself.  Don’t be scared: we are diving a bit into expert stuff here, but only to prove the point.  You can do a lot with very little.

RELATED:   Top Four Reasons to use Cube Panel

So how do you do it?

Even by cPanel standards this is one of the easier functions to perform. Scroll down in your cPanel home page.  You’ll probably find “Cron Jobs” in the Advanced section. Click on it and you’ll be asked whether you like it easy or hard.  Personal preferences aside, there’s not much reason to go hard. Click on “Standard” to get to the main cron jobs screen.

cron jobs cpanel

You will first enter the email address that the results of the cron job will be sent: if it is not successful, the email will contain the error message, though this may require some debugging on your part.  Next you will enter the command.  One unavoidable technical note: the command must be typed in using the full path.  So if you are running a script that is in your home directory, you must specify the full server path to it.

RELATED:   Consider ISPmanager When Starting a Web Hosting Business

Get your timing right

Now you need to specify how often you want the cron job to run.  Most of this is self-explanatory, though there is at least one potentially confusing item.  You can specify the days that the job will run both by days of the month and days of the week.  That’s not confusing by itself, but what happens if you choose both?  Let’s look at the combinations.

  • “Days” = “Every Day” and “Week Days” = “Every Week Day”: This will run the cron job on every single day.
  • “Days” = “2” and “Week Days” = “Every Week Day”: This will run the job on the 2nd day of the month only.
  • “Days” = “Every Day” and “Week Days” = “Tuesday”: This will run the job on every Tuesday.
  • “Days” = “2” and “Week Days” = “Tuesday”: This will run the job on the 2nd Tuesday of the month only.
RELATED:   A Walk through the Mail Section in cPanel

That’s it!

Now hit “Save Crontab” and you’re done!  You can then go back to this later and delete or modify the job.  Note that you can also create mulitple cron jobs, even if they use the same commands.  You might want to, say, backup a certain directory every day, and your entire account every month.

Now the only thing you need to do is learn the commands you want to run.  This should make clear that this is worth the effort.  Cron jobs are one of the most useful basic tools for just about any developer, and cPanel makes using them even easier.

Comments

1 Comment

  • Avatar Host1free says:

    You are the best writer who gives all the new knowledge and informations.

    great work dude…

    thanks for keeping us updated..

Leave a Reply

Your email address will not be published. Required fields are marked *