【 Crontab in Linux 】What is it? + Characteristics and Uses ▷ 2022

For manage tasks that are repetitive, it is necessary to schedule the processes with a temporal frequency. For this the is used, which is helped by a file called Crontab.

in this file the way in which the processes must be managed is established for each user. But this is not all you should know about crontab, since it has other secrets that you should keep in mind.

If you want know more about Crontab, we invite you to continue reading this post. you will know what type of tasks can be scheduled and the steps you must do in it.

What are Crontab commands and what are they for in Linux?

Before knowing how the Crontab command works it is necessary to know what another command, cron, is for. The latter is a program that is used, inside a linux terminalevery time you need to run processes in background at a precise moment. This means that the action will take place (for example) every minute, every day, every certain number of hours, or once a week.

To specify how it should work cron it is necessary to write the instructions in a specific file, called crontab. This element is a text file that is saved within the command and that can be individualized and customized by each user. From all this it follows that Crontab is a file that is saved inside the cron command to specify the instructions that are necessary to carry out the task of the main command.

What kind of tasks can be scheduled using Crontab commands in Linux?

See also  【 ColorZilla 】What is it? + How to Use it ▷ 2022

Among the tasks that can be scheduled using Crontab in Linux are:

  • Activate a notification for remember events at a certain moment.
  • Program update setting the day and time you want this process to run.
  • start your in background at a specific time.
  • that they meet in .
  • Customize permissions user every certain period.
  • save a file at an exact time of day.
  • Request user access password once a week.

Learn step by step how to use Crontab to automate tasks in Linux

The step by step that you must do to use Crontab correctly and thus automate tasks in Linux is the following:

start crontab

The first thing you will have to do is create a script, which will work with cron and thus can follow the instructions that you want the command to carry out at a certain moment. We will take as an example that you need the operating system update to be done automatically.

For this you will have to enter the console and write:

#!/bin/bash #script name of automatic update mode #type your Linux distribution #apt-get update & apt-get -y upgrade (in case your distro is Ubuntu or Debian, you will have to remove #) #fedora #yum -y update #Arch #pacman –noconfirm -Syu

After what you have created this script you will have to save it as update.sh and change execution permissions by typing chmod a+x ~/scripts/update.sh.

add tasks

What you will have to do now is include what you want done from time to time (in our example it is the OS update, but you can also run the antivirus, check email, etc). To add a task you will have to use the argument -e, which will help you choose a text editor.

See also  【 WHATSAPP CLONED! 】How to avoid it? Step by Step Guide ▷ 2022

This will allow the Crontab file to be:

  • # mh dom mon dow user command

In this way you will have to enter the corresponding minutes to run the script (m)The exact time (h)the day of the month the task will be performed (sun) and the day of the week (dow)can also be numeric by writing 1 like Sunday). For more information, look carefully at the image in this post, it will help you understand all the variables. You will also have to write the username (user) and the path to access the script (command).

Examples of this are:

  • For update every day at 11.30 am the script you will have to write 30 11 * * * user /home/user/scripts/update.sh.
  • In case of want to run it on November 20 at 6:30 p.m. you will have to write 30 18 11 20 sun user /home/user/scripts/update.sh.
Loading Facebook Comments ...
Loading Disqus Comments ...