Home/Posts/Administración del Hosting/GUIDE CREATE A CRON TASK IN CPANEL (I) 2020 -WAU

Create a cron task in CPanel to delete files from a directory

The automation of repetitive tasks or processes It is part of the day-to-day management and administration of the web for medium and / or advanced users or for system administrators, and its good use augurs a more exhaustive control of the processes that are executed, when and how so that time dedicated to performing these tasks manually can be used to perform others.

Deleting temporary files, cache files, or emptying email folders sent to the trash can be some of the daily tasks or processes that we can do automatically by using cron, through the Hosting Panel (if you have this functionality) to keep the contracted disk quotas more controlled or healthy.

It is possible to create as many tasks as processes you want to automate at the Hosting level (as user) as long as these processes can be run from the command line. Many extensions, mainly those focused on sending newsletters or others, allow you to schedule tasks to be performed from Cron Jobs in the Hosting Panel.

What is cron?

Chron, from the Greek “chronos” (time), is the name of the application distributed in Linux / Unix that allows processes or scripts to be run automatically at regular intervals (groups of commands) at a specific time and time.

The official definition would be “a demon that runs scheduled programs. ”

This demon or service, called crond, is executed on the server, where it must previously be started, what generally happens with the system startup.

What is crontab?

When we set up a rule or task we call it Crontab and it is a text file that stores a list of commands to be executed in a time determined by the user.

Crontab Verify the execution date and time of the task collected in a script or command, the execution permissions that you will have by carrying out that task in the background.


A crontab made and executed by a user (user crontab) consists of six fields and arguments (one or more):

1 2 3 4 5 / script_path_or_command arg1 arg2

1 = minutes: goes from 0 to 59 and represents the minute it runs

2 = hours: goes from 0 to 23 and represents the time it runs

3 = day month: runs from 1 to 31 and is the day of the month it runs

4 = month: ranges from 1 to 12 and represents the month it runs

5 = day week: it goes from 0 to 7 and the day of the week it runs (Sunday can be indicated with 0 or 7, Monday is 1, Tuesday 2, etc.)

command: is the command to execute (a command or the path to a shell script that we want to execute.)

* * * * * comando a ejecutar
- - - - -
| | | | |
| | | | ----- Día de la semana (0 - 7) (Domingo=0 o 7)
| | | ------- Mes (1 - 12)
| | --------- Día del mes (1 - 31)
| ----------- Hora (0 - 23)
------------- Minuto (0 - 59)


  • With an asterisk * everything is indicated, that is, every minute, or every month, or every day.
  • With a comma , a list of values ​​is specified (1,5,10,15,20, 25).
  • With a hyphen a series of values ​​are specified (5-15 days, equivalent to writing 5,6,7,8,9, …, 13,14,15).
  • With a bar / an increment of values ​​is specified, for example: 1-10 / 2. Values ​​in increment of 2 in 2, starting from 1, that is: 1,3,5,7,9

The cron tasks can be created from the Hosting Panel, Advanced, Cron Jobs and based on the syntax explained, build scripts that will run on the date and times defined to download manual tasks to the user, automating them.

In the following video by Jordi Sala you can see how Cron Jobs is managed from cpanel.

At next chapter We will explain how to schedule tasks to delete or empty files from certain folders in Joomla, WordPress or PrestaShop.

Member of the Websites Are Us technical team.
Coordinator of content on the Blog and YouTube.
Technical support in CyberProtector. Teacher at Websites Are Us Learning.

By |2020-05-12T01:32:28+00:00May 12th, 2020|Administración del Hosting|