I run jupyter noteboook on a server.
To start it, I have the following script:
#!/bin/sh exec &> /home/user/logfile2.txt echo 'running jup.sh' >> /home/user/logfile2.txt cd /home/user/jup unset XDG_RUNTIME_DIR pipenv run jupyter notebook &
sudo crontab file looks like:
@reboot sleep 20 && /usr/scripts/jup.sh
It has also looked like:
@reboot sleep 20 && /usr/scripts/jup.sh & -or- @reboot sleep 20 && /home/user/jup.sh & -or- @reboot (sleep 20 && /usr/scripts/jup.sh) > /dev/null
The script will output the file echo portion of the file, and I've echo'd out the working directory as well. As far as I can tell the only thing that doesn't execute is the "pipenv ..." command.
- I recently upgraded from 17.10, to 18.04 LTS. It used to work under the 'regular' crontab instead of the sudo.
- The script will start the jupyter notebook at the shell.
I implemented the recommendations to add the full path for pipenv and for
. /etc/profile. Neither resolved the issue.
I also deleted the first line of the script and received a mail stating that it couldn't find the full path. It said that it needed the full path. I added the full path and that error went away. Therefore, the full path was part of my problem.
I have a similar script that runs a gunicorn server for a django app. It too works from the shell, but not from @reboot. It too used to work with @reboot.
Edit 2: Email received about the error: (This has been fixed by adding the path)
From firstname.lastname@example.org Thu Jun 13 11:25:23 2019 Return-Path: <email@example.com> X-Original-To: root Delivered-To: firstname.lastname@example.org Received: by experiments.local (Postfix, from userid 0) id 05966E144D; Thu, 13 Jun 2019 11:25:23 -0700 (PDT) From: email@example.com (Cron Daemon) To: firstname.lastname@example.org Subject: Cron <root@experiments> (sleep 20 && /usr/scripts/jup.sh) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root> Message-Id: <20190613182523.05966E144D@experiments.local> Date: Thu, 13 Jun 2019 11:25:23 -0700 (PDT) /usr/scripts/jup.sh: 13: /usr/scripts/jup.sh: pipenv: not found
#!/bin/sh . /etc/profile #exec &> /home/john/logfile2.txt echo 'running jup.sh' >> /home/john/logfile2.txt cd /home/john/jup echo $PWD >> /home/john/logfile2.txt unset XDG_RUNTIME_DIR /usr/local/bin/pipenv run jupyter notebook &
juypter is an IDE for code exploration. jupyter.org. I installed it via instructions here: https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html
Root: I've run it both in sudo crontab and regular crontab. Prior to the last couple of days it has not been run as root. As part of troubleshooting, I've run the script in both, to see it makes a difference. It has not.