What are common cron job examples?

Here are some common cron job examples along with their explanations:

  1. Run a Script Every Minute:

    * * * * * /path/to/your/script.sh
    

    This runs the script every minute.

  2. Run a Script Every Hour:

    0 * * * * /path/to/your/script.sh
    

    This runs the script at the start of every hour.

  3. Run a Script Every Day at Midnight:

    0 0 * * * /path/to/your/script.sh
    

    This runs the script every day at midnight.

  4. Run a Script Every Sunday at 3 AM:

    0 3 * * 0 /path/to/your/script.sh
    

    This runs the script every Sunday at 3 AM.

  5. Run a Script on Weekdays at 9 AM:

    0 9 * * 1-5 /path/to/your/script.sh
    

    This runs the script at 9 AM from Monday to Friday.

  6. Run a Script on the First Day of Every Month at 6 AM:

    0 6 1 * * /path/to/your/script.sh
    

    This runs the script at 6 AM on the first day of each month.

  7. Run a Script Every 15 Minutes:

    */15 * * * * /path/to/your/script.sh
    

    This runs the script every 15 minutes.

  8. Run a Script at 5 PM on Weekdays:

    0 17 * * 1-5 /path/to/your/script.sh
    

    This runs the script at 5 PM from Monday to Friday.

  9. Run a Script at 10 PM on the Last Day of the Month:

    0 22 L * * /path/to/your/script.sh
    

    This runs the script at 10 PM on the last day of the month.

These examples can be modified to fit your specific scheduling needs by adjusting the time and command as necessary.

0 Comments

no data
Be the first to share your comment!