Skip to content

Commit

Permalink
CTX-5758: Fix for crontab scheduling new job on every activateAutoUpd…
Browse files Browse the repository at this point in the history
…ate() function call. (#228)

* CTX-5758: Fix for crontab scheduling new job on every activateAutoUpdate() call.

* CTX-5758: Discussion changes.

---------

Co-authored-by: Bogdan Tintor <btintor@biomech.us>
  • Loading branch information
bogdant36 and Bogdan Tintor committed Jul 3, 2024
1 parent cc855a7 commit 823c1b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions coretex/cli/modules/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def getExisting() -> List[str]:

def jobExists(script: str) -> bool:
existingLines = getExisting()
return any(line.endswith(script) for line in existingLines)
return any(script in line for line in existingLines)


def scheduleJob(scriptName: str) -> None:
existingLines = getExisting()
existingLines.append(f"*/30 * * * * {CONFIG_DIR / scriptName} >> {CONFIG_DIR}/logs/ctx_autoupdate.log 2>&1\n")
cronJob = f"*/30 * * * * {CONFIG_DIR / scriptName} >> {CONFIG_DIR}/logs/ctx_autoupdate.log 2>&1\n"
existingLines.append(cronJob)

tempCronFilePath = CONFIG_DIR / "temp.cron"
with tempCronFilePath.open("w") as tempCronFile:
Expand Down
2 changes: 1 addition & 1 deletion coretex/cli/modules/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def activateAutoUpdate() -> None:
updateScriptPath = DEFAULT_VENV_PATH.parent / UPDATE_SCRIPT_NAME
dumpScript(updateScriptPath)

if not jobExists(UPDATE_SCRIPT_NAME):
if not jobExists(str(updateScriptPath)):
scheduleJob(UPDATE_SCRIPT_NAME)


Expand Down

0 comments on commit 823c1b0

Please sign in to comment.