No time for commands? Let’s schedule your tasks with CRON !

Try Cron to execute your demand command automatically !


Hi, I'm Nghi. Welcome back to my blog ?

Because I am taking training courses so I have opportunities to take research a variety of new knowledge day by day. And I found out one interesting topic which impressed to me , that is CRON

What is Cron and What is it used for ? Check it now below!

1. What is Crob?

I think that when you are taking responsibility as a sysadmin, one of the challenges (among the many advantages) is running tasks when you'd rather be sleeping. For example, some tasks (including regularly recurring tasks) need to run overnight or on weekends for tracking, when no one is expected to be using computer resources. And we can not have time to spare in the evenings to run commands and scripts that have to operate during off-hours. Such as:

  • You can install the cron job to perform a scan to see which user trials have been expired and deleted or set inactive their accounts.
  • Send emails to users using the system daily or weekly ...
  • Delete cache files every month when it's too big
  • Check daily that the links of the website are broken or not to quickly fix
  • Database backup

Similar to Windows, Linux also has a way to create and run commands at a specified time. In Windows it is called Task Schedule, while for Linux it is Cron.

And we have two definitions: Cronjobs are orders that execute preset actions at a given time. Crontab is where Cronjobs are stored.

2.How does it work ?

A cron schedule is simply a text file. Each user has a separate cron schedule, this file is usually located in /var/spool/cron. Crontab files do not allow you to create or edit directly with any text editor, unless you use the crontab command.

Some commonly used commands:

  • crontab -e: create or edit crontab files
  • crontab -l: display crontab file
  • crontab -r: delete crontab file

3. Structure:

A crontab file has 5 time-defined fields, and the last command is to be run periodically, structured as follows:

If a column is assigned the * character, it means that the task will then be run at every value for that column.

In my research , I use Cron to execute the access log file at 13rd minute every hour:

4. Online tools for create Cron Execute command in Shell Script:

I used

And in your Instance , using : $sudo crontab -e to access to the Cron scripts and edit to create access log file

6. Summary:

Cron gives you a variety advantages when you are tracking and executing the system.  Let's try it!


I am just a beginner so I will try to discover more and write more to share with you ?

 Thank you!