Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
es:docs:guide-user:base-system:cron [2023/12/26 16:35] – created brodrigueznues:docs:guide-user:base-system:cron [2023/12/26 18:02] – Minor changes brodrigueznu
Line 10: Line 10:
  
 ===== Objetivos ===== ===== Objetivos =====
-  * Run programs or scripts at a specific time+  * Ejecutar programas o scripts en un momento específico
-  * Automate scheduled task management.+  * Automatizar la gestión de tareas programadas.
  
-===== Web interface instructions ===== +===== Instrucciones de la interfaz web ===== 
-Set up cron jobs using web interface+Configurar tareas cron usando la interfaz web. 
-  - Navigate to **LuCI -> System -> Scheduled Tasks**. +  - Navegue a **LuCI -> System -> Scheduled Tasks**. 
-  - Edit the configuration and click the **Save** button.+  - Edite la configuración y haga clic en el botón **Save**.
  
-===== Command-line instructions ===== +===== Instrucciones de línea de comando ===== 
-Set up cron jobs using command-line interface.+Configurar tareas cron usando la interfaz de línea de comandos.
  
 <code bash>  <code bash> 
-Edit configuration+Editar configuración
 crontab -e  crontab -e 
  
-Show configuration+Mostrar configuración
 crontab -l crontab -l
  
-Apply changes+Aplicar cambios
 service cron restart service cron restart
 </code> </code>
  
-This will edit the configuraion ''/etc/crontabs/root'' file in [[docs:guide-user:base-system:user.beginner.cli#editing_files|vi editor]].+Esto editará el archivo de configuración ''/etc/crontabs/root'' en el [[es:docs:guide-user:base-system:user.beginner.cli#editing_files|editor vi]].
  
-:!: There should be a EOL character on the last line of the crontab file+:!: Debe haber un carácter EOL en la última línea del archivo crontab. 
-Just leave an empty line at the end to be sure.+Simplemente deje una línea vacía al final para estar seguro.
  
-===== Task specification ===== +===== Especificación de tarea ===== 
-Each line is a separate task written in the specification:+Cada línea es una tarea separada escrita en la especificación:
  
 <code> <code>
-* * * * * command to execute+* * * * * comando a ejecutar
 - - - - - - - - - -
 | | | | | | | | | |
-| | | | ----- Day of week (0 - 6) (Sunday =0) +| | | | ----- Día de la semana (0 - 6) (Domingo =0) 
-| | | ------- Month (1 - 12) +| | | ------- Mes (1 - 12) 
-| | --------- Day (1 - 31) +| | --------- Día (1 - 31) 
-| ----------- Hour (0 - 23) +| ----------- Hora (0 - 23) 
-------------- Minute (0 - 59)+------------- Minuto (0 - 59)
 </code> </code>
  
-Examples of time specification:+Ejemplos de especificación de tiempo:
  
-^  min\\ 0-59  ^  hour\\ 0-23  ^  day/month\\ 1-31  ^  month\\ 1-12  ^  day/week\\ 0-6  ^ Description +^  min\\ 0-59  ^  hora\\ 0-23  ^  día del mes\\ 1-31  ^  mes\\ 1-12  ^  día de la semana\\ 0-6  ^ Descripción 
-|  */5  |  *  |  *  |  *  |  *  | Every minutes +|  */5  |  *  |  *  |  *  |  *  | Cada minutos 
-|  12  |  */3  |  *  |  *  |  *  | Every hours at 12 minutes +|  12  |  */3  |  *  |  *  |  *  | Cada horas a los 12 minutos 
-|  57  |  11  |  15  | 1,6,12 |  *  | At 11:57 Hrs on 15th of JanJune Dec +|  57  |  11  |  15  | 1,6,12 |  *  | A las 11:57 Hrs el día 15 de EneJun Dic 
-|  25  |  6  |  *  |  *  |  1-5  | At 6:25 AM every weekday (Mon-Fri) | +|  25  |  6  |  *  |  *  |  1-5  | A las 6:25 AM cada día laboral (Lun-Vie) | 
-|  0  |  0  |  4,12,26  |  *  |  *  | At midnight on 4th12th and 26th of every month +|  0  |  0  |  4,12,26  |  *  |  *  | A la medianoche los días 412 y 26 de cada mes 
-|  5,10  |  9,14  |  10  |  *  |  0,4  | At 9:05AM, 9:10AM, 2:05PM and 2:10PM every Sunday and Thursday |+|  5,10  |  9,14  |  10  |  *  |  0,4  | A las 9:05AM, 9:10AM, 2:05PM 2:10PM cada domingo y jueves |
  
-:!: 0 (zerois treated as Sunday+:!: 0 (cerose trata como domingo
-If you set the day of the week to 7, BusyBox will go bonkers and run your command every day.+Si configura el día de la semana en 7, BusyBox se volverá loco y ejecutará su comando todos los días.
  
-**Table of shortcuts:**+**Tabla de atajos:**
  
-Shortcut Equivalent Description +Atajo Equivalencia Descripción 
-| ''@reboot'' | | Run onceat startup +| ''@reboot'' | | Ejecutar una vezal inicio 
-| ''@yearly'' | ''0 0 1 1 *''Every year +| ''@yearly'' | ''0 0 1 1 *''Cada año 
-| ''@annually'' | ''0 0 1 1 *''Every year +| ''@annually'' | ''0 0 1 1 *''Cada año 
-| ''@monthly'' | ''0 0 1 * *''Every month +| ''@monthly'' | ''0 0 1 * *''Cada mes 
-| ''@weekly'' | ''0 0 * * 0''Every week +| ''@weekly'' | ''0 0 * * 0''Cada semana 
-| ''@daily'' | ''0 0 * * *''Every day +| ''@daily'' | ''0 0 * * *''Cada día 
-| ''@midnight'' | ''0 0 * * *''Every day +| ''@midnight'' | ''0 0 * * *''Cada día 
-| ''@hourly'' | ''0 * * * *''Every hour |+| ''@hourly'' | ''0 * * * *''Cada hora |
  
-:!:  Time shortcuts are not enabled by defaultShortcuts require compiling busybox with FEATURE_CROND_SPECIAL_TIMES enabled in the busybox compile options.+:!:  Los atajos de tiempo no están habilitados de forma predeterminadaLos accesos directos requieren compilar Busybox con FEATURE_CROND_SPECIAL_TIMES habilitado en las opciones de compilación de Busybox.
  
-===== Troubleshooting ===== +===== Solución de problemas ===== 
-You can read log messages with:+Puede leer mensajes de registro con:
  
 <code bash> <code bash>
Line 85: Line 85:
 </code> </code>
  
-Not all messages are loggedto increase logging change ''[[docs:guide-user:base-system:system_configuration|cronloglevel]]'' option.+No todos los mensajes se registranpara aumentar el registro cambie la opción ''[[es:docs:guide-user:base-system:system_configuration|nivel de registro cron]]''.
  
 ===== Extras ===== ===== Extras =====
-==== References ====+==== Referencias ====
   * [[man>crontab(1)]], [[man>crontab(5)]]   * [[man>crontab(1)]], [[man>crontab(5)]]
   * [[https://busybox.net/downloads/BusyBox.html#crontab|BusyBox crontab]]   * [[https://busybox.net/downloads/BusyBox.html#crontab|BusyBox crontab]]
   * [[http://adminschoice.com/crontab-quick-reference|Crontab quick reference]]   * [[http://adminschoice.com/crontab-quick-reference|Crontab quick reference]]
  
-==== Periodic reboot ==== +==== Reinicio periódico ==== 
-A simple workaround for some hard-to-solve problems (memory leakperformance degradation, ...) is to reboot the router periodicallyfor instance every night.+Una solución sencilla para algunos problemas difíciles de resolver (pérdida de memoriadegradación del rendimiento,...) es reiniciar el enrutador periódicamentepor ejemplo cada noche.
  
-Howeverthis is not as simple as it seemsbecause the router usually does not have a real-time clock+Sin embargoesto no es tan sencillo como pareceya que el router no suele tener un reloj en tiempo real. 
-This could lead to a never-ending loop of reboots.+Esto podría provocar un ciclo interminable de reinicios.
  
-In the boot process the clock is initially set by ''sysfixtime'' to the most recent timestamp of any file found in /etc. +En el proceso de arranque, el reloj se configura inicialmente mediante "sysfixtime" con la marca de tiempo más reciente de cualquier archivo que se encuentre en /etc. 
-The most recent file is possibly a status file or config filemodified maybe 30 seconds before the reboot initiated by cron. +El archivo más reciente es posiblemente un archivo de estado o un archivo de configuraciónmodificado quizás 30 segundos antes del reinicio iniciado por cron. 
-Soin the boot process the clock gets set backwards a few seconds to that file's timestamp+Entoncesen el proceso de arranque, el reloj se retrasa unos segundos hasta la marca de tiempo de ese archivo
-Then cron starts and notices a few seconds later that the required boot moment has again arrived and reboots again... +Luego, cron se inicia y unos segundos más tarde nota que el momento de inicio requerido ha llegado de nuevo y se reinicia nuevamente... 
-At the end of the boot process ntpd startsand it may also take a while before ntpd gets and sets the correct timeso cron may start the reboot in between.+Al final del proceso de arranque, se inicia ntpd, y también puede pasar un tiempo antes de que ntpd obtenga y establezca la hora correctapor lo que cron puede iniciar el reinicio en el medio.
  
-One solution for cron is to use a delay and touch a file in ''/etc'' before reboot.+Una solución para cron es utilizar un retraso y tocar un archivo en ''/etc'' antes de reiniciar.
  
 <code bash> <code bash>
-Reboot at 4:30am every day +Reiniciar a las 4:30 a. m. todos los días 
-NoteTo avoid infinite reboot loopwait 70 seconds +NotaPara evitar un bucle de reinicio infinitoespere 70 segundos 
-and touch a file in /etc so clock will be set +y toque un archivo en /etc para configurar el reloj 
-properly to 4:31 on reboot before cron starts.+correctamente a las 4:31 a.m. al reiniciar antes de que comience cron.
 30 4 * * * sleep 70 && touch /etc/banner && reboot 30 4 * * * sleep 70 && touch /etc/banner && reboot
 </code> </code>
  
-:!: On many platforms ''shutdown'' does not workit will just halt the CPU but it won't power off the device+:!: En muchas plataformas ''shutdown'' no funcionasimplemente detendrá la CPU pero no apagará el dispositivo
-There is usually no programmable circuitry to actually power off the unit+Por lo general, no hay ningún circuito programable para apagar la unidad
-''reboot'' does workin case you should want to reboot the router periodically.+''reboot'' funcionaen caso de que desee reiniciar el enrutador periódicamente.
  
-==== Periodic network restart ==== +==== Reinicio periódico de la red ==== 
-A simple solution for restart all your network (lan, wan and wifi) every 10 minutes is this:+Una solución sencilla para reiniciar toda su red (lan, wan wifi) cada 10 minutos es esta:
  
 <code bash> <code bash>
Line 126: Line 126:
 </code> </code>
  
-==== Alarm clock ==== +==== Despertador ==== 
-If you have [[wp>Daylight saving time|DST]] you could write yourself a nice alarm clock+Si tiene [[wp>Daylight saving time|DST - Hora de verano]] podría escribirse un bonito despertador
-When DST starts in central Europeclocks advance from 02:00 CET to 03:00 CEST on last Sunday in March+Cuando comienza el horario de verano en Europa Centrallos relojes avanzan de las 02:00 CET a las 03:00 CEST del último domingo de marzo
-Six day before thatyou could make your WoL wake you 10 minutes earlier+Seis días antespodría hacer que su WoL le despierte 10 minutos antes
-Later won't workyou'll be late+Más tarde no funcionarállegará tarde
-When DST ends in central Europeclocks retreat from 03:00 CEST to 02:00 CET on last Sunday in October.+Cuando finaliza el horario de verano en Europa Centrallos relojes retroceden de las 03:00 CEST a las 02:00 CET del último domingo de octubre.
  
 <code bash> <code bash>
-# min hour day month dayofweek command+# min hora día mes día-de-la-semana comando
 59 05 * * 1 /usr/bin/wol -h 192.168.1.255 xx:xx:xx:xx:xx:xx 59 05 * * 1 /usr/bin/wol -h 192.168.1.255 xx:xx:xx:xx:xx:xx
-# crontab must end with the last line as space or a comment+# crontab debe terminar con la última línea como espacio o comentario
 </code> </code>
  
-==== Keep number of configs snapshots of config ==== +==== Mantener el número de configuraciones/instantáneas de configuración ==== 
-To keep a number of configurations/settings at the directory "/root", you can also use cron. This way you can access and restore configurations of the past daysThe cronjob can easily be extended to copy the config to another deviceto be able to replicate a broken OpenWRT device from scratch.+Para mantener un número de configuraciones/valores en el directorio "/root", también puede utilizar cron. De esta forma podrás acceder y restaurar configuraciones de los últimos díasEl cronjob se puede ampliar fácilmente para copiar la configuración a otro dispositivopara poder replicar un dispositivo OpenWRT roto desde cero.
  
 <code bash> <code bash>
-#Make a new backup/configurations snapshot at nighttime 00:01 amkeep last N=100 snapshots +#Hacer una nueva instantánea de copia de seguridad/configuraciones durante la noche a la 12:01 a. m.conserve las últimas N=100 instantáneas 
-#01 00 * * * sysupgrade -b "/root/backup-${HOSTNAME}.tar.gz" # <-- keep just one config+#01 00 * * * sysupgrade -b "/root/backup-${HOSTNAME}.tar.gz" # <-- mantiene solo una configuración
 01 00 * * * find "/root" -type f -name "backup-*.tar.gz" | sort -r | awk 'NR > 100' | xargs rm -f; sysupgrade -b "/root/backup-${HOSTNAME}-$(date +\%Y-\%m-\%d-\%H-\%M-\%S).tar.gz" 01 00 * * * find "/root" -type f -name "backup-*.tar.gz" | sort -r | awk 'NR > 100' | xargs rm -f; sysupgrade -b "/root/backup-${HOSTNAME}-$(date +\%Y-\%m-\%d-\%H-\%M-\%S).tar.gz"
 </code> </code>
  
  • Last modified: 2023/12/26 18:26
  • by brodrigueznu