Skip to content

Instantly share code, notes, and snippets.

@adojos
Last active March 27, 2023 08:47
Show Gist options
  • Select an option

  • Save adojos/f809966ed813904382602131c82db995 to your computer and use it in GitHub Desktop.

Select an option

Save adojos/f809966ed813904382602131c82db995 to your computer and use it in GitHub Desktop.

Revisions

  1. adojos revised this gist Mar 27, 2023. 1 changed file with 13 additions and 49 deletions.
    62 changes: 13 additions & 49 deletions crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -58,55 +58,19 @@

    ### Examples

    Execute specified script twice a day at 6 AM and 6 PM daily:
    ```
    0 6,18 * * * script.sh
    ```

    Execute specified script twice daily at 5PM and 17PM:
    ```
    0 5,17 * * * script.sh
    ```

    Execute specified script every minute:
    ```
    * * * * * script.sh
    ```

    Execute specified script every every day at 00:00:
    ```
    0 0 * * * script.sh
    ```

    Execute specified script every 5th minute:
    ```
    */5 * * * * script.sh
    ```

    Execute specified script every day at 8 AM:
    ```
    0 8 * * * script.sh
    ```

    Execute specified script every hour at minute 0:
    ```
    0 * * * * script.sh
    ```

    Execute specified script every Sunday at 5 PM _(Non standard! May not work with every cron)_:
    ```
    0 17 * * sun script.sh
    ```

    Execute specified script on selected months _(Non standard! May not work with every cron)_:
    ```
    * * * jan,may,aug * script.sh
    ```

    Execute specified script every four hours:
    ```
    0 */4 * * *
    ```
    | Commands | Description |
    | :-----------------------------| ------------------------------------: |
    | Execute specified script twice a day at 6 AM and 6 PM daily | `0 6,18 * * * script.sh` |
    | Execute specified script twice daily at 5PM and 17PM | `0 5,17 * * * script.sh` |
    | Execute specified script every minute | `* * * * * script.sh` |
    | Execute specified script every every day at 00:00 | `0 0 * * * script.sh` |
    | Execute specified script every 5th minute | `*/5 * * * * script.sh` |
    | Execute specified script every day at 8 AM | `0 8 * * * script.sh` |
    | Execute specified script every hour at minute 0 | `0 * * * * script.sh` |
    | Execute specified script every Sunday at 5 PM _(Non standard! May not work with every cron)_ | `0 17 * * sun script.sh` |
    | Execute specified script on selected months _(Non standard! May not work with every cron)_ | `* * * jan,may,aug * script.sh` |
    | Execute specified script every four hours | `0 */4 * * *` |


    </br>

  2. adojos revised this gist Mar 25, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    </br>

    ### Common Commands

    | Commands | Description |
    | :-----------------------------| ----------------------------------------: |
    | `crontab -e` | Edit crontab file, or create one if it doesn’t already exist. |
  3. adojos revised this gist Mar 25, 2023. 1 changed file with 62 additions and 40 deletions.
    102 changes: 62 additions & 40 deletions crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -1,98 +1,120 @@
    ## CronTab Essential Commands With Examples
    ## CronTab Basic Commands With Examples

    </br>

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `crontab -e` | Edit crontab file, or create one if it doesn’t already exist. |
    | `crontab -l` | List cronjobs, display crontab file contents |
    | `crontab -r` | Remove your crontab file |
    | `crontab -u UserName -r` | Delete all crontab jobs of the named user |
    | `crontab -v` | Display the last time you edited your crontab file. (This option is only available on a few systems.) |
    | `crontab -u UserName -l` | List all crontab jobs for the named user|
    | `crontab -u UserName -l` | List all crontab jobs for the named user|
    | Commands | Description |
    | :-----------------------------| ----------------------------------------: |
    | `crontab -e` | Edit crontab file, or create one if it doesn’t already exist. |
    | `crontab -l` | List cronjobs, display crontab file contents |
    | `crontab -r` | Remove your crontab file |
    | `crontab -u UserName -r` | Delete all crontab jobs of the named user |
    | `crontab -v` | Display the last time you edited your crontab file. (This option is only available on a few systems.) |
    | `crontab -u UserName -l` | List all crontab jobs for the named user|

    </br>

    ### Command Switches/Parameters

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `-u` | Specifies the user whose crontab is to be viewed or modified. If this option is not given, crontab opens the crontab of the user who ran crontab |
    | `-l` | Display the current crontab. |
    | `-r` | Remove the current crontab. |
    | `-e` | Edit the current crontab, using the editor specified in the environment variable |
    | `-i` | Same as -r, but gives the user a yes/no confirmation prompt before removing the crontab |
    | Commands | Description |
    | :-----------------------------| -----------------------------------------: |
    | `-u` | Specifies the user whose crontab is to be viewed or modified. If this option is not given, crontab opens the crontab of the user who ran crontab |
    | `-l` | Display the current crontab. |
    | `-r` | Remove the current crontab. |
    | `-e` | Edit the current crontab, using the editor specified in the environment variable |
    | `-i` | Same as -r, but gives the user a yes/no confirmation prompt before removing the crontab |

    </br>

    ### Time and Date Fields

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `minute` | Minutes, expressed as a whole number from 0-59 |
    | `hour` | Hour, expressed as a whole number from 0-23 |
    | `day of month` | Day of the month, ranging from 1-31. The asterisk indicates that task can run on any day of the month |
    | `month` | Month, which can range from 1-12. The asterisk indicates that task can run on any month of year |
    | `day of week` | Day of the week. This is represented by a number from 0-7. Zero or 7 is Sunday. 1 is Monday. 6 is Saturday |
    | Commands | Description |
    | :-----------------------------| -------------------------------------------: |
    | `minute` | Minutes, expressed as a whole number from 0-59 |
    | `hour` | Hour, expressed as a whole number from 0-23 |
    | `day of month` | Day of the month, ranging from 1-31. The asterisk indicates that task can run on any day of the month |
    | `month` | Month, which can range from 1-12. The asterisk indicates that task can run on any month of year |
    | `day of week` | Day of the week. This is represented by a number from 0-7. Zero or 7 is Sunday. 1 is Monday. 6 is Saturday |

    </br>

    ### Shorthand Keywords

    Note: Keywords given below are non-standard and may not run on every system.
    :point_right: *Note*: _Keywords given below are non-standard and may not run on every system._

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `@reboot` | Run once at startup |
    | `@yearly` | Run once a year (0 0 1 1 *) |
    | `@annually` | Same as @yearly |
    | `@monthly` | Run once a month (0 0 1 * *) |
    | `@weekly` | Run once a week (0 0 * * 0) |
    | `@daily` | Run once a day (0 0 * * *) |
    | `@midnight` | Same as @daily |
    | `@hourly` | Run once an hour (0 * * * *) |
    | Commands | Description |
    | :-----------------------------| ------------------------------------: |
    | `@reboot` | Run once at startup |
    | `@yearly` | Run once a year (0 0 1 1 *) |
    | `@annually` | Same as @yearly |
    | `@monthly` | Run once a month (0 0 1 * *) |
    | `@weekly` | Run once a week (0 0 * * 0) |
    | `@daily` | Run once a day (0 0 * * *) |
    | `@midnight` | Same as @daily |
    | `@hourly` | Run once an hour (0 * * * *) |

    </br>

    ### Examples

    Execute specified script twice a day at 6 AM and 6 PM daily:
    ```
    0 6,18 * * * script.sh
    ```

    Execute specified script twice daily at 5PM and 17PM:
    ```
    0 5,17 * * * script.sh
    ```

    Execute specified script every minute:
    ```
    * * * * * script.sh
    ```

    Execute specified script every every day at 00:00:
    ```
    0 0 * * * script.sh
    ```

    Execute specified script every 5th minute:
    ```
    */5 * * * * script.sh
    ```

    Execute specified script every day at 8 AM:
    ```
    0 8 * * * script.sh
    ```

    Execute specified script every hour at minute 0:
    ```
    0 * * * * script.sh
    ```

    Execute specified script every Sunday at 5 PM:
    Execute specified script every Sunday at 5 PM _(Non standard! May not work with every cron)_:
    ```
    0 17 * * sun script.sh
    ```

    Execute specified script on selected months:
    Execute specified script on selected months _(Non standard! May not work with every cron)_:
    ```
    * * * jan,may,aug * script.sh
    ```

    Execute specified script every four hours:
    ```
    0 */4 * * *
    ```

    </br>

    ### Online Cron Job Generators

    https://crontab.guru/
    [CronTab Guru](https://crontab.guru/)

    https://www.freeformatter.com/cron-expression-generator-quartz.html
    [Cron Expression Generator Quartz](https://www.freeformatter.com/cron-expression-generator-quartz.html)

    https://crontab-generator.org/
    [CronTab Generator](https://crontab-generator.org/)



  4. adojos revised this gist Mar 25, 2023. 1 changed file with 92 additions and 7 deletions.
    99 changes: 92 additions & 7 deletions crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,98 @@
    ## CronTab Essential Commands
    ## CronTab Essential Commands With Examples

    </br>

    | Commands | Description |
    | :------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
    | `crontab -e` | Edit crontab file, or create one if it doesn’t already exist. |
    | `crontab -l` | List cronjobs, display crontab file contents |
    | `crontab -r ` | Remove your crontab file |
    | `crontab -v` | Display the last time you edited your crontab file. (This option is only available on a few systems.) |
    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `crontab -e` | Edit crontab file, or create one if it doesn’t already exist. |
    | `crontab -l` | List cronjobs, display crontab file contents |
    | `crontab -r` | Remove your crontab file |
    | `crontab -u UserName -r` | Delete all crontab jobs of the named user |
    | `crontab -v` | Display the last time you edited your crontab file. (This option is only available on a few systems.) |
    | `crontab -u UserName -l` | List all crontab jobs for the named user|
    | `crontab -u UserName -l` | List all crontab jobs for the named user|

    </br>

    ### Command Switches/Parameters

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `-u` | Specifies the user whose crontab is to be viewed or modified. If this option is not given, crontab opens the crontab of the user who ran crontab |
    | `-l` | Display the current crontab. |
    | `-r` | Remove the current crontab. |
    | `-e` | Edit the current crontab, using the editor specified in the environment variable |
    | `-i` | Same as -r, but gives the user a yes/no confirmation prompt before removing the crontab |

    </br>

    ### Time and Date Fields

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `minute` | Minutes, expressed as a whole number from 0-59 |
    | `hour` | Hour, expressed as a whole number from 0-23 |
    | `day of month` | Day of the month, ranging from 1-31. The asterisk indicates that task can run on any day of the month |
    | `month` | Month, which can range from 1-12. The asterisk indicates that task can run on any month of year |
    | `day of week` | Day of the week. This is represented by a number from 0-7. Zero or 7 is Sunday. 1 is Monday. 6 is Saturday |

    </br>

    ### Shorthand Keywords

    Note: Keywords given below are non-standard and may not run on every system.

    | Commands | Description |
    | :-----------------------------| ------------------------------------------------------------------------: |
    | `@reboot` | Run once at startup |
    | `@yearly` | Run once a year (0 0 1 1 *) |
    | `@annually` | Same as @yearly |
    | `@monthly` | Run once a month (0 0 1 * *) |
    | `@weekly` | Run once a week (0 0 * * 0) |
    | `@daily` | Run once a day (0 0 * * *) |
    | `@midnight` | Same as @daily |
    | `@hourly` | Run once an hour (0 * * * *) |

    </br>

    ### Examples

    Execute specified script twice a day at 6 AM and 6 PM daily:
    0 6,18 * * * script.sh

    Execute specified script every minute:
    * * * * * script.sh

    Execute specified script every every day at 00:00:
    0 0 * * * script.sh

    Execute specified script every 5th minute:
    */5 * * * * script.sh

    Execute specified script every day at 8 AM:
    0 8 * * * script.sh

    Execute specified script every hour at minute 0:
    0 * * * * script.sh

    Execute specified script every Sunday at 5 PM:
    0 17 * * sun script.sh

    Execute specified script on selected months:
    * * * jan,may,aug * script.sh

    Execute specified script every four hours:
    0 */4 * * *

    </br>

    ### Online Cron Job Generators

    https://crontab.guru/

    https://www.freeformatter.com/cron-expression-generator-quartz.html

    https://crontab-generator.org/



  5. adojos revised this gist Mar 24, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## CronTab Commands Reference
    ## CronTab Essential Commands

    </br>

  6. adojos revised this gist Mar 24, 2023. No changes.
  7. adojos revised this gist Mar 24, 2023. 1 changed file with 4 additions and 17 deletions.
    21 changes: 4 additions & 17 deletions crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -4,24 +4,11 @@

    | Commands | Description |
    | :------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
    | `crontab -e` | This is used to edit or create a new crontab ile |
    | `ls -al ~/.ssh` | List existing SSH Keys from standard SSH folder in user profile folder |
    | `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` | Generating SSH Keys using SSH-Keygen tool of OpenSSH |
    | `eval $(ssh-agent -s)` | Starts the SSH-Agent in the background |
    | `ssh-add ~/.ssh/id_rsa` | Adds your Private key to SSH-Agent |
    | `ssh -T git@github.com` | Testing your GitBash authentication with Github |
    | `ssh-keygen -p` | Changing passphrase of an existing SSH Key |
    | `ssh-add -D` | For removing 'ALL' private keys from the SSH-Agent |
    | `ssh-add -d /home/user/.ssh/id_rsa` | For removing 'A Single' named private key from the SSH-Agent |
    | `eval $(ssh-agent -s)` | Starts the SSH-Agent |
    | `ssh-add -l` | To list the ssh-keys currently available with SSH-Agent |
    | `ssh-add -L` | With the -L option, the keys in the SSH-Agent can be listed as well. While the -l option shows the fingerprint for each key, the -L option shows the public key part of each key. |
    | `eval $(ssh-agent -s -k)` | To terminate the SSH-Agent the following command can be executed. kill the SSH-Agent. |
    | `crontab -e` | Edit crontab file, or create one if it doesn’t already exist. |
    | `crontab -l` | List cronjobs, display crontab file contents |
    | `crontab -r ` | Remove your crontab file |
    | `crontab -v` | Display the last time you edited your crontab file. (This option is only available on a few systems.) |

    <br/>

    ## Reference Links

    [Official OpenSSH Commands Reference](https://www.openssh.com/manual.html)

    </br>
  8. adojos revised this gist Mar 24, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    | Commands | Description |
    | :------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
    | `crontab -e` | Prints SSH-Agent verion information |
    | `crontab -e` | This is used to edit or create a new crontab ile |
    | `ls -al ~/.ssh` | List existing SSH Keys from standard SSH folder in user profile folder |
    | `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` | Generating SSH Keys using SSH-Keygen tool of OpenSSH |
    | `eval $(ssh-agent -s)` | Starts the SSH-Agent in the background |
  9. adojos revised this gist Mar 24, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    | Commands | Description |
    | :------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
    | `ssh -V` | Prints SSH-Agent verion information |
    | `crontab -e` | Prints SSH-Agent verion information |
    | `ls -al ~/.ssh` | List existing SSH Keys from standard SSH folder in user profile folder |
    | `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` | Generating SSH Keys using SSH-Keygen tool of OpenSSH |
    | `eval $(ssh-agent -s)` | Starts the SSH-Agent in the background |
  10. adojos revised this gist Mar 24, 2023. No changes.
  11. adojos revised this gist Mar 24, 2023. 1 changed file with 27 additions and 1 deletion.
    28 changes: 27 additions & 1 deletion crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,27 @@
    ‎‎​
    ## CronTab Commands Reference

    </br>

    | Commands | Description |
    | :------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
    | `ssh -V` | Prints SSH-Agent verion information |
    | `ls -al ~/.ssh` | List existing SSH Keys from standard SSH folder in user profile folder |
    | `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` | Generating SSH Keys using SSH-Keygen tool of OpenSSH |
    | `eval $(ssh-agent -s)` | Starts the SSH-Agent in the background |
    | `ssh-add ~/.ssh/id_rsa` | Adds your Private key to SSH-Agent |
    | `ssh -T git@github.com` | Testing your GitBash authentication with Github |
    | `ssh-keygen -p` | Changing passphrase of an existing SSH Key |
    | `ssh-add -D` | For removing 'ALL' private keys from the SSH-Agent |
    | `ssh-add -d /home/user/.ssh/id_rsa` | For removing 'A Single' named private key from the SSH-Agent |
    | `eval $(ssh-agent -s)` | Starts the SSH-Agent |
    | `ssh-add -l` | To list the ssh-keys currently available with SSH-Agent |
    | `ssh-add -L` | With the -L option, the keys in the SSH-Agent can be listed as well. While the -l option shows the fingerprint for each key, the -L option shows the public key part of each key. |
    | `eval $(ssh-agent -s -k)` | To terminate the SSH-Agent the following command can be executed. kill the SSH-Agent. |

    <br/>

    ## Reference Links

    [Official OpenSSH Commands Reference](https://www.openssh.com/manual.html)

    </br>
  12. adojos created this gist Mar 24, 2023.
    1 change: 1 addition & 0 deletions crontab-commands-reference.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    ‎‎​