tiburon-security / jupyterlab_scheduler

Jupyter Lab Plugin for scheduling recurring execution of files within the UI using Cron
MIT License
24 stars 18 forks source link

Keep getting "Bad minute" error, even though cron syntax seems correct #18

Open remyvanlis opened 2 years ago

remyvanlis commented 2 years ago

Just installed a fresh installation of ubuntu, installed python, npm, pip and JupyterHub, did everything I wanted in the configs and it all just seems to work fine. However, after installing Jupyterlab_scheduler, I noticed it would always throw a "bad minute" error:

traceback: "Traceback (most recent call last):\n File \"/usr/local/lib/python3.9/dist-packages/tornado/web.py\", line 1702, in _execute\n result = method(*self.path_args, **self.path_kwargs)\n File \"/usr/local/lib/python3.9/dist-packages/tornado/web.py\", line 3173, in wrapper\n return method(self, *args, **kwargs)\n File \"/home/amuseic/.local/lib/python3.9/site-packages/jupyterlab_scheduler/handlers.py\", line 119, in post\n job.setall(schedule)\n File \"/home/amuseic/.local/lib/python3.9/site-packages/crontab.py\", line 235, in __exit__\n self.write()\n File \"/home/amuseic/.local/lib/python3.9/site-packages/crontab.py\", line 360, in write\n raise IOError(\"Program Error: {} returned {}: {}\".format(\nOSError: Program Error: /usr/bin/crontab returned 1: **b'\"/tmp/tmpfv9g75nc\":7: bad minute\\nerrors in crontab file, can\\'t install.\\n'\n"**

Even though I'm using copy-pasted syntax from Cron themselves:

image

No idea how to fix this myself, no idea what might be going wrong.

remyvanlis commented 2 years ago

Noticed something else. The error ends with a statement about a file in /tmp, which contains API calls to 127.0.0.1:8081:

image

But when actually trying to access this on 127.0.0.1:8081, I get a 500 internal server error after logging in. What I've actually hosted it on is 0.0.0.0, in my case 192.168.178.82:8888. This is due to the fact that I access it through nginx with some A records in my hosting service.

image

Could it have anything to do with me changing the default host?

yangs0459 commented 2 years ago

It cased by JUPYTERHUB_OAUTH_SCOPES="["access:servers!server=abc/", ""]".

I update file jupyterlab_scheduler/handlers.py around line 118 as below: `with CronTab(user=os.environ["USER"]) as cron: for key, value in os.environ.items():

cron.env[key] = value

            try:
               cron.env[key] = json.loads(value)
            except Exception:
               cron.env[key] = value

`

Then restart jupyterhub, it can success add cronjob.