diff --git a/src/pyinfra/operations/crontab.py b/src/pyinfra/operations/crontab.py index b7849af50..e8ba66f8e 100644 --- a/src/pyinfra/operations/crontab.py +++ b/src/pyinfra/operations/crontab.py @@ -84,7 +84,9 @@ def comma_sep(value): ctb = ctb0 name_comment = "# pyinfra-name={0}".format(cron_name) - existing_crontab = ctb.get_command(command=command, name=cron_name) + existing_crontab = ctb.get_command( + command=command if cron_name is None else None, name=cron_name + ) existing_crontab_command = existing_crontab["command"] if existing_crontab else command existing_crontab_match = existing_crontab["command"] if existing_crontab else command