Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
Add crontab documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusgava committed Jul 7, 2018
1 parent ee4c695 commit 5d59d30
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Notification Body
**Required:** Yes
**Placeholder Available:** Yes

# Usage - Local
## Usage - Local
Makefile and instruction bellow expected you uses python3.
It also expected you already have a chrome webdrive installed.

Expand All @@ -122,19 +122,65 @@ It also expected you already have a chrome webdrive installed.
3. Edit ``src/settings/local.py`` file with your information.
4. Run ``python3 src/app.py local`

# Integrations Placeholder
## Integrations Placeholder
Some integration fields accept placeholder, that means you can use internal fields used on integration on your texts.
Fields that accept placeholders are marked on **Env Variables** of each integration.

## Placeholder syntax
### Placeholder syntax
``%(placeholderName)s``
Example:
``This is my holerite at %(search_year)s/%(search_month)s``

## Available placeholders
### Available placeholders
- search_year
- search_month

## Crontab

First create bash like this:
````bash
#!/bin/bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

# print current date at log
date

# GET LAST MONTH YEAR AND MONTH
LAST_MONTH_YEAR=$(perl -MPOSIX=strftime -le '@t = localtime; $t[3] = 1; $t[5]--; print strftime("%Y", @t)')
LAST_MONTH_MONTH=$(perl -MPOSIX=strftime -le '@t = localtime; $t[3] = 1; $t[4]--; print strftime("%m", @t)')

# try 5 times
n=0
until [ $n -ge 5 ]
do
echo "trying $n"
/usr/local/bin/docker run --env-file "$SCRIPTPATH/env-configs" \
-e RH_SEARCH_YEAR="$LAST_MONTH_YEAR" \
-e RH_SEARCH_MONTH="$LAST_MONTH_MONTH" \
viniciusgava/portaldorh-holerite-download:latest 2>&1 && break
n=$[$n+1]
sleep 15
done

````
**Mac tip:** You must to pass docker full path to works at crontab
``/usr/local/bin/docker``

Second add all env variables at ``env-configs``.
Example:
````bash
RH_USERNAME='YOUR USERNAME HERE'
RH_PASSWORD='YOUR PASSWORD HERE'
````

Then run ``crontab -e`` and add the follow cron.
Example:
````bash
0 8 7 * * sh ~/automate/holerite/run.sh >> ~/automate/holerite/holerite.log
````
The example bellow runs 8am of day 7 of every month.
You can generate a different crontab config on [https://crontab-generator.org](https://crontab-generator.org)

## Links
- [GitHub](https://github.com/viniciusgava/portaldorh-holerite-download)
- [Docker Hub](https://hub.docker.com/r/viniciusgava/portaldorh-holerite-download/)

0 comments on commit 5d59d30

Please sign in to comment.