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")