Scheduled tasks, or cron jobs, are processes that run automatically in the background. Generally speaking, a cron job is a Linux utility that sets a command or a set of commands to execute at specific times or frequencies to perform specific tasks on any VPS (/vps). Using cron jobs, you can automate specific tasks, such as sending automated emails, automatic backups, clearing your server\'s cache, deleting temporary files, and basically anything you can think of. Some practical examples of using cron jobs include receiving emails at 7 AM from a department store, receiving government payments, or your mobile phone alarm going off. The use of cron jobs is not a theoretical novelty; it\'s a utility that has supported technological development for years and is important for understanding the algorithmic processes that occur automatically.

How to install Cron Jobs on Linux? To install this utility, you must run the following command on your Debian / Ubuntu machine:

 

The above command will install the utility, creating a file called crontab in the /etc/ directory (/etc/crontab)

How to edit Crontab in Linux?

To edit crontab in Debian/Ubuntu, you can use your favorite editor; in our case, we\'ll use nano.
 
nano /etc/crontab 
This will open a file with example syntax like the following:
 
SHELL=/bin/sh 
PATH=/usr/local/sbin :/usr/local/bin:/sbin:/bin :/usr/sbin:/usr/bin 

17     root cd / && run-parts --report /etc/cron.hourly 
25 6   * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 
47 6   7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1   root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) 

Basic crontab / cronjob syntax

The basic syntax structure for running crontab is as follows:
 
minute hour day_of_month month day_of_week command_to_execute 
A basic example of using crontab to run a URL at 7 AM:
0 7   * curl https://mox.cl
In this case, at 7 AM, it executes the CURL function to access the website in question (the asterisk represents any number or, in this example, any day). Another basic example, to reset the RAM of your Debian/Ubuntu virtual machine, could be:
0     free -m

Conclusions

Without a doubt, running cron jobs will make running any task easier. Securely automatable (since it happens within your VPS). You can execute tasks using commands directly on your server or run scripts you\'ve written in another programming language. In addition to running tasks on your own virtual server, you can execute tasks externally using CURL or WGET. When using cPanel hosting, you can manage these commands more easily using the Cron Jobs module available in cPanel. Alternatively, if you use a VPS with cPanel or DirectAdmin, there are platforms with templates that allow you to run these tasks. When using a CMS like PrestaShop or WordPress, you can directly install a module that allows you to automate these tasks, such as cache generation and cleanup.