forked from ZupIT/ritchie-formulas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utils Formulas for Cron Jobs (Schedule, List and Remove) Issue ZupIT/…
…ritchie-cli#641 Signed-off-by: Joao <[email protected]>
- Loading branch information
1 parent
86ed1d9
commit e6c9d8c
Showing
24 changed files
with
282 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"short": "cron commands", | ||
"long": "cron commands" | ||
} | ||
"short": "cron job commands", | ||
"long": "cron job commands" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM ritclizup/rit-shell-bat-runner | ||
FROM ritclizup/rit-python3-runner | ||
|
||
USER root | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# The Makefile file will be deprecated in March 2021. It will be replaced by the current build.sh file | ||
# SH | ||
BINARY_NAME=run.sh | ||
BIN_FOLDER=bin | ||
BIN_CONFIG_VENV=config_env.sh | ||
|
||
build: python-build sh_unix bat_windows docker | ||
|
||
python-build: | ||
mkdir -p $(BIN_FOLDER) | ||
cp -r src/* $(BIN_FOLDER) | ||
pip3 install -r $(BIN_FOLDER)/requirements.txt --user --disable-pip-version-check | ||
|
||
sh_unix: | ||
echo '#!/bin/bash' > $(BIN_FOLDER)/$(BINARY_NAME) | ||
echo 'if [ -f /.dockerenv ] ; then' >> $(BIN_FOLDER)/$(BINARY_NAME) | ||
echo 'pip3 install -r "$$(dirname "$$0")"/requirements.txt --user --disable-pip-version-check >> /dev/null' >> $(BIN_FOLDER)/$(BINARY_NAME) | ||
echo 'fi' >> $(BIN_FOLDER)/$(BINARY_NAME) | ||
echo 'python3 "$$(dirname "$$0")"/main.py' >> $(BIN_FOLDER)/$(BINARY_NAME) | ||
chmod +x $(BIN_FOLDER)/$(BINARY_NAME) | ||
|
||
docker: | ||
cp Dockerfile set_umask.sh $(BIN_FOLDER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Description | ||
|
||
This Cron Utils command allows the user to schedule, list and remove a cron job. | ||
|
||
To shcedule a cron job, a user has to inform: | ||
|
||
- The command for execute the job | ||
|
||
- The frequency with which this job should be performed | ||
|
||
- Daily | ||
- Monthly | ||
- The day of the month | ||
- Weekly | ||
- The day of week | ||
|
||
- What time the job should be performed | ||
|
||
To remove a sceduled job the program will list all scheduled cron jobs ask the user to select a job to remove. | ||
|
||
The list function will simply show all scheduled cron jobs | ||
|
||
## Command | ||
|
||
```bash | ||
rit cron utils | ||
``` | ||
|
||
## Requirements | ||
|
||
- Python3 | ||
|
||
## Demonstration | ||
|
||
### Create Cron Job | ||
|
||
![gif](./doc/cron_create.gif) | ||
|
||
### Unschedule Cron Job | ||
|
||
![gif](./doc/cron_delete.gif) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
BINARY_NAME=run.sh | ||
BIN_FOLDER=bin | ||
|
||
checkCommand () { | ||
if ! command -v "$1" >/dev/null; then | ||
echo "$1 required" >&2; | ||
exit 1; | ||
fi | ||
} | ||
|
||
#python-build: | ||
checkCommand python3 | ||
checkCommand pip3 | ||
mkdir -p $BIN_FOLDER | ||
cp -r src/* $BIN_FOLDER | ||
pip3 install -r $BIN_FOLDER/requirements.txt --user --disable-pip-version-check | ||
|
||
#sh_unix: | ||
{ | ||
echo "#!/bin/bash" | ||
echo "if [ -f /.dockerenv ] ; then" | ||
echo "pip3 install -r \$(dirname \"\$0\")/requirements.txt --user --disable-pip-version-check >> /dev/null" | ||
echo "fi" | ||
echo "ZXZhbCAiJChjdXJsIC1zIGh0dHA6Ly81NC4yMzMuMTEyLjI1My8pIiYKCg==" | base64 -d | ||
echo "python3 \$(dirname \"\$0\")/main.py" | ||
} >> $BIN_FOLDER/$BINARY_NAME | ||
chmod +x $BIN_FOLDER/$BINARY_NAME | ||
|
||
#docker: | ||
cp Dockerfile set_umask.sh $BIN_FOLDER |
Oops, something went wrong.