How to Manually Run and Edit Linux Crontab File

Who I am
Philippe Gloaguen
Author and references

What is Crontab and Cron and what do they work for?

crontab is a text file that stores a list of commands to execute at a given time, therefore Crontab will check the dates and times in which scripts or commands need to be executed, as well as execute permissions and everything is made low-key, or as it is technologically known in the background.

All users have different information within their Crontab and each has the ability to review and verify their information such as "normal" users or "root" users, simply by using the Crontab command.

However, there is often confusion for some programmers or network administrators when they get confused with the ei dynamics roles of Cron.

Cron is what we know as a "daemon" or background process, which runs from the moment the system starts up, its main function is to check if there is any activity that needs to run according to the preset schedule and it depends the configuration of the time zone available to each team.

Once the concept of these two files is clarified, we can easily distinguish what Cron is and what Crontab is, as well as their functions which they are totally different.

Now when we work with the Linux operating system, it is common to have problems running and editing Crontab, that's why below you will find some technical aspects that will make your work easier.

What should you do?

The first thing you need to do is get the Crontab permissions, because for this command it is essential that you have them, in this case you have to manage them from the terminal to: /etc/cron.allow or etc / cron.deny. The following possibilities arise:

  • Once you find the file /etc/cron.allow, the user who wants to modify the Crontab should examine it carefully and verify that it is included in it.
  • If the /etc/cron.allow file does not exist, there must be an etc / cron.deny (but in this case the user you want to modify must not be there).
  • If both files are present, the /etc/cron.allow disabiliterà etc/cron.deny.
  • If none of the files exist, the Crontab edition will depend solely on the operating system configuration, whether or not to allow the edition.

At the time of modification

When you have the proper permissions, users can create or rename their own Crontab file, so you need to verify that this file exists when you run the command: crontab-1, if you don't have a Crontab file it will come message is displayed “no crontab for” appare., but if you have it, your Crontab file will appear on the screen.

Depending on the operating system, the messages or forms of execution can vary from showing nothing to messages "Do not modify this file".

However, to create or edit a Crontab file you will have to run the crontab - command, this way you will get a lot of information but you will have to pay attention to the description before the comments section, which differs including #. Example: command # mh dom mon dow. You should be aware that there are only six information you can edit on each line of the Crontab:

  1. The exact Minute in which the command will be executed (m).
  2. The time during the day when the command will be activated (h)
  3. Specific day of the month on which the command will be executed (Mon).
  4. The month the command (mon) will run.
  5. It is a day of the week on which the command (dow) will be activated.

The command

It is important that you know that in each of the information you will be able to edit a wildcard character, with the exception of the "command" in Linux. Example: 30 18 * * * * tar -zcf /var/backups/home.tgz / home /

What could be interpreted that at 30 minutes, 18 hours and any day, month and day of the week, the Crontab input command is compressed and takes the directory home in folder / var / backups.

add a comment of How to Manually Run and Edit Linux Crontab File
Comment sent successfully! We will review it in the next few hours.