From 74201e59d69184c59b50e47f339cf6381dab3f97 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Thu, 3 Aug 2023 16:35:58 +0200 Subject: [PATCH] allow wrapper to work as a daemon-restarter... --- cronwrapper/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cronwrapper/__init__.py b/cronwrapper/__init__.py index 79d9e83..d213321 100755 --- a/cronwrapper/__init__.py +++ b/cronwrapper/__init__.py @@ -47,6 +47,10 @@ def parse_args(): '-L', '--no-lock', help='Allow multiple simultanious executions of this cron job', action='store_true') + parser.add_argument( + '-r', '--restart', + help='Restart the process if not running; exit with success if previous instance is running', + action='store_true') parser.add_argument( @@ -189,6 +193,8 @@ def main(): has_lock = aquire_lock(lckfile) if has_lock: res = exec_command(args, o, e, r) + elif args.restart: + res = 0 else: e.write("CRONWRAPPER: Unable to aquire lock, previous instance still running?\n") r.write("\nFalse\n")