Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
How do I efficiently setup a Linux crontab to run a script every Saturday of the month except the first Saturday

I want to run a script every Saturday except for the first Saturday of each month. (The script monitors a maintenance window, and the window is longer on the first Saturday of the month.)

Here is what I have:

*/15 17-18 8-31 * * [ "$(date '+\%a')" = "Sat" ] && <Then run my script>

Here is what I'm looking at:

*/15 17-18 *    * 6 [ "$(date '+\%d')" > "7" ] && <Then run my script>

I feel like the first example creates too many unnecessary attempts as it runs every day after the first seven days of the month but only will process the monitoring script on Saturdays.

In the second example, I'm attempting to run the script only on Saturdays but only if the day of the month is greater than 7. I'm not sure how to do it using the 'day of the month' result from the date command, and I'm not sure if this will work. Specifically, should I use the '>' symbol or a 'gt' bash-like function?

Is there a better way to achieve this other than what I have here?

Thanks for your input. I've looked at other examples similar to this but most of them only addressed running a script on the first weekend of the month.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try this:

*/15 17-18 * * 6 [ $(date '+\%d') -gt 7 ] && <Then run your script>

From help test:

-gt: greater-than

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda