Linux - Resumen de crontab
Listar las entradas de crontab:
sudo crontab -l
Editar las entradas de crontab:
sudo crontab -e
Formato:
* * * * * /bin/myscript.sh
1. minute (from 0 to 59)
2. hour (from 0 to 23)
3. day of month (from 1 to 31)
4. month (from 1 to 12)
5. day of week (from 0 to 6) (0=Sunday)
Ejemplos:
*Ejecutar algo cada minuto:
* * * * * /bin/myscript.sh
1.every minute
2.every hour
3.every day of the month
4.every month
5.every day in the week
Nota: * --> every
*Ejecutar cada viernes a las 02:00h:
0 2 * * 5 /bin/myscript.sh
1.minute: 0
2.hour: 2
3.day: * (every day of month)
4.month: * (every month)
5.weekday: 5 (=Friday)
*Ejecutar de Lunes a Viernes a las 02:00h:
0 2 * * 1-5 /bin/myscript.sh
1.minute: 0
2.hour: 2
3.day: * (every day of month)
4.month: * (every month)
5.weekday: 1-5 (=Monday till Friday)
*Ejecutar pasados diez minutos de cada hora, el primer dia de cada mes:
10 * 1 * * /bin/myscript.sh
*Ejecutar cada 10 minutos:
0,10,20,30,40,50 * * * * /bin/myscript.sh
Almacenar la salida
*/10 * * * * /bin/myscript.sh 2>&1 >> /var/log/myscript_output.log
30 12 * * * /u01/app/oracle/bin/rman_backup.pl > /u01/app/oracle/log/rman_backup_$(date +\%Y\%m\%d_\%H:\%M:\%S\%z).log 2>&1
sudo crontab -l
Editar las entradas de crontab:
sudo crontab -e
Formato:
* * * * * /bin/myscript.sh
1. minute (from 0 to 59)
2. hour (from 0 to 23)
3. day of month (from 1 to 31)
4. month (from 1 to 12)
5. day of week (from 0 to 6) (0=Sunday)
Ejemplos:
*Ejecutar algo cada minuto:
* * * * * /bin/myscript.sh
1.every minute
2.every hour
3.every day of the month
4.every month
5.every day in the week
Nota: * --> every
*Ejecutar cada viernes a las 02:00h:
0 2 * * 5 /bin/myscript.sh
1.minute: 0
2.hour: 2
3.day: * (every day of month)
4.month: * (every month)
5.weekday: 5 (=Friday)
*Ejecutar de Lunes a Viernes a las 02:00h:
0 2 * * 1-5 /bin/myscript.sh
1.minute: 0
2.hour: 2
3.day: * (every day of month)
4.month: * (every month)
5.weekday: 1-5 (=Monday till Friday)
*Ejecutar pasados diez minutos de cada hora, el primer dia de cada mes:
10 * 1 * * /bin/myscript.sh
*Ejecutar cada 10 minutos:
0,10,20,30,40,50 * * * * /bin/myscript.sh
Almacenar la salida
*/10 * * * * /bin/myscript.sh 2>&1 >> /var/log/myscript_output.log
30 12 * * * /u01/app/oracle/bin/rman_backup.pl > /u01/app/oracle/log/rman_backup_$(date +\%Y\%m\%d_\%H:\%M:\%S\%z).log 2>&1
Comentarios