5 asterisks in the CRONTAB file. What does it mean?

2

My query is about what the following command means in my linux system, I know it is a bash of CONTRAB but I can not understand why it uses five asterisks:

* * * * * curl http://mi-ws/obtenerMensaje
    
asked by Luis De La Peña 04.01.2019 в 21:43
source

2 answers

3

The tasks cron follow a certain syntax.

* * * * *  /ejecutar_comando

De izquierda a derecha, los asteriscos representan:

1. Minutos: de 0 a 59
2. Horas: de 0 a 23
3. Día del mes: de 1 a 31
4. Mes: de 1 a 12
5. Día de la semana: de 0 a 6, siendo 0 el domingo

In the example * * * * * means:

1. Cada minuto
2. Cada hora
3. Cada día del mes
4. Cada mes
5. Cada día de la semana

Another example:

30 2 * * 1 /ejecutar_comando

1. En el minuto 30
2. De las 2 de la noche
3. De cada día del mes
4. De cada mes
5. Sólo si es viernes
    
answered by 04.01.2019 / 21:51
source
0

man 5 crontab establishes that the value of the asterisk (*) is taken as the values from the first to the last accepted value of each "first-last" field. A "*" in the field of minutes, would be equivalent to "0-59", analogous to the other fields.

The values accepted by field are:

field          allowed values
-----          --------------
minute         0-59
hour           0-23
day of month   1-31
month          1-12 (or names, see below)
day of week    0-7 (0 or 7 is Sun, or use names)

Where, on the day of the week, 1 is Monday, 5 is Friday, 0 and 7 is Sunday.

I put it this way because there will be notations of the form:

*/2 */6 * * * etc

That will be equivalent to

0-59/2 0-23/6 1-31 1-12 0-6 etc

Regarding your question about the user who executes the task. Each user has their own crontab. If you make a sudo crontab -e , you will edit the crontab file of the root user, at the same time that if you do crontab -e from a user, you will edit that user's crontab file.

    
answered by 04.01.2019 в 23:15