code: def _setup_crontab():
      
      from crontab import CronTab
      #Since CI works out of a virtualenv anyway, the `ci.py` script will be
      #installed in the bin already, so we can call it explicitly.
      command = '/bin/bash -c "source ~/.cron_profile; workon {}; ci.py -cron"'.format(settings.venv)
      user = _get_real_user()
      if args["nolive"]:
          vms("Skipping cron tab configuration because 'nolive' enabled.")
          return
      cron = CronTab(user=user)
      
      #We need to see if the cron has already been created for this command.
      existing = False
      possible = cron.find_comment("pyci_cron")
      if len(list(possible)) > 0:
          if args["rollback"]:
              vms("Removing {} from cron tab.".format(command))
              cron.remove_all(command)
              cron.write()
              db["cron"] = False
              _save_db()
          else:
              existing = True
      
      if not existing and not args["rollback"]:
          job = cron.new(command=command, comment="pyci_cron")
          #Run the cron every minute of every hour every day.
          if args["cronfreq"] == 1:
              vms("New cron tab configured *minutely* for {}".format(command))
              job.setall("* * * * *")
          else:
              vms("New cron tab configured every {} minutes for {}.".format(args["cronfreq"], command))
              job.setall("*/{} * * * *".format(args["cronfreq"]))
          cron.write()
          db["cron"] = True
          _save_db()
docs: Sets up the crontab if it hasn't already been setup.