1. 1. DAY 11 πŸ‘Ύ
    1. 1.0.1. I’m back πŸ’™
      1. 1.0.1.1. Today I created a Cron Job to run Github Trending Script Every 3 hours so that the data remains updated.
  • 2. So what is a Cron Job ?
    1. 2.1. Cron is a daemon, viz, a background process which runs at a specified time. If we want to take a backup daily then instead of doing it manually every fucking day, we write a script & provide it to cron, then cron runs the script in that specified time. What if we shut down our PC or Lappy at the specified time. Then, the script won’t run instead we need to use anacron.
  • 3. Anacron is the cron for desktops and laptops. It does not expect the system to be running 24 x 7 like a server.
    1. 3.1. For example, if we have to send an Email to our subscribers daily at 9 PM as a regular cron job, and if our laptop is not ON at 9 PM, the Email won’t be sent.
      1. 3.1.1. However, if we have the same job scheduled in anacron, we can be sure that it will be executed once the laptop is ON.
  • 4. Syntax of crontab (field description)
    1. 4.1. The syntax is:
      1. 4.1.1. 1 2 3 4 5 /path/to/command arg1 arg2
      2. 4.1.2. OR
      3. 4.1.3. 1 2 3 4 5 /root/email.sh
        1. 4.1.3.1. Where,
      4. 4.1.4. 1: Minute (0-59)
      5. 4.1.5. 2: Hours (0-23)
      6. 4.1.6. 3: Day (0-31)
      7. 4.1.7. 4: Month (0-12 [12 == December])
      8. 4.1.8. 5: Day of the week(0-7 [7 or 0 == sunday])
      9. 4.1.9. /path/to/command – Script or command name to schedule
  • 5. Easy to remember format:
  • 6. * command to be executed
  • 7. - - - - -
  • 8. | | | | |
  • 9. | | | | —– Day of week (0 - 7) (Sunday=0 or 7)
  • 10. | | | β€”β€”- Month (1 - 12)
  • 11. | | β€”β€”β€” Day of month (1 - 31)
  • 12. | ———– Hour (0 - 23)
  • 13. β€”β€”β€”β€”- Minute (0 - 59)
    1. 13.0.1. Here’s my runGithubTrending script
    2. 13.0.2. So, here’s how we can runGithubTrending script every 3 hours using Cron
    3. 13.0.3. Till the next time πŸ‘»
  • Run Github Trending Every 3 Hours and Push to Github

    DAY 11 πŸ‘Ύ

    I’m back πŸ’™

    So what is a Cron Job ?

    Cron is a daemon, viz, a background process which runs at a specified time. If we want to take a backup daily then instead of doing it manually every fucking day, we write a script & provide it to cron, then cron runs the script in that specified time. What if we shut down our PC or Lappy at the specified time. Then, the script won’t run instead we need to use anacron.

    Anacron is the cron for desktops and laptops. It does not expect the system to be running 24 x 7 like a server.

    For example, if we have to send an Email to our subscribers daily at 9 PM as a regular cron job, and if our laptop is not ON at 9 PM, the Email won’t be sent.

    However, if we have the same job scheduled in anacron, we can be sure that it will be executed once the laptop is ON.

    Syntax of crontab (field description)

    The syntax is:

    1 2 3 4 5 /path/to/command arg1 arg2

    OR

    1 2 3 4 5 /root/email.sh

    Where,

    1: Minute (0-59)

    2: Hours (0-23)

    3: Day (0-31)

    4: Month (0-12 [12 == December])

    5: Day of the week(0-7 [7 or 0 == sunday])

    /path/to/command – Script or command name to schedule

    Easy to remember format:

    * command to be executed

    - - - - -

    | | | | |

    | | | | —– Day of week (0 - 7) (Sunday=0 or 7)

    | | | β€”β€”- Month (1 - 12)

    | | β€”β€”β€” Day of month (1 - 31)

    | ———– Hour (0 - 23)

    β€”β€”β€”β€”- Minute (0 - 59)

    Here’s my runGithubTrending script

    1
    2
    3
    4
    5
    $ cd 'full/path/to/github-trending'
    $ yarn start
    $ git add -A
    $ git commit -m "Update"
    $ git push origin master

    So, here’s how we can runGithubTrending script every 3 hours using Cron

    1
    $ crontab -l | { cat; echo "0 */3 * * * runGithubTrending"; } | crontab -

    Till the next time πŸ‘»