mirror of
https://github.com/netinvent/npbackup.git
synced 2025-11-12 15:11:40 +08:00
GUI: Fix task creation for unix
This commit is contained in:
parent
710bced957
commit
32c5dd2543
1 changed files with 6 additions and 4 deletions
|
|
@ -94,19 +94,21 @@ def create_scheduled_task_unix(
|
||||||
):
|
):
|
||||||
executable_dir = os.path.dirname(cli_executable_path)
|
executable_dir = os.path.dirname(cli_executable_path)
|
||||||
if "python" in sys.executable:
|
if "python" in sys.executable:
|
||||||
cli_executable_path = sys.executable + " " + cli_executable_path
|
cli_executable_path = f'"{sys.executable}" "{cli_executable_path}"'
|
||||||
|
else:
|
||||||
|
cli_executable_path = f'"{cli_executable_path}"'
|
||||||
cron_file = "/etc/cron.d/npbackup"
|
cron_file = "/etc/cron.d/npbackup"
|
||||||
if interval_minutes:
|
if interval_minutes:
|
||||||
TASK_ARGS = f"-c {config_file} --backup"
|
TASK_ARGS = f'-c "{config_file}" --backup'
|
||||||
trigger = f"*/{interval_minutes} * * * *"
|
trigger = f"*/{interval_minutes} * * * *"
|
||||||
elif hour and minute:
|
elif hour and minute:
|
||||||
TASK_ARGS = f"-c {config_file} --backup --force"
|
TASK_ARGS = f'-c "{config_file}" --backup --force'
|
||||||
trigger = f"{minute} {hour} * * *"
|
trigger = f"{minute} {hour} * * *"
|
||||||
else:
|
else:
|
||||||
raise ValueError("Bogus trigger given")
|
raise ValueError("Bogus trigger given")
|
||||||
|
|
||||||
crontab_entry = (
|
crontab_entry = (
|
||||||
f'{trigger} cd "{executable_dir}" && "{cli_executable_path}" {TASK_ARGS}'
|
f'{trigger} cd "{executable_dir}" && {cli_executable_path} {TASK_ARGS}\n'
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with open("/etc/cron.d/npbackup", "w") as file_handle:
|
with open("/etc/cron.d/npbackup", "w") as file_handle:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue