Server Ubuntu 16.04 running in a Virtual Box.
I had a server which I needed to rebuild (had no backups). I copied all relevant scripts I needed to reuse and all work as expected except one which is called from root cron. This worked well and without issues before. The script starts jupyter notebook in a screen session and when executed manually does what it is supposed to do. The script is:
#!/bin/bash
# cd /home/<username>/jupyternb
screen -S jupyter -dm jupyter notebookThe crontab line is as follows:
@reboot sh /home/<username>/.STARTUP_SCRIPTS/start_jupyter.sh(<username> is an actual user)
The shell script permissions are 777.
syslog shows the script is being called as root and reports no issues.
Any pointers appreciated.
32 Answers
If syslog shows that job is being called then it could be a path issue.
Try to put the whole path /usr/bin/screen in script instead of just screen command.
#!/bin/bash
# cd /home/<username>/jupyternb /usr/bin/screen -S jupyter -dm jupyter notebookAlso you need to have end of line after each line in crontab, if that is the last line and there is no end of line character, job will not start.
Try checking with mail command for system mail of root user, or use MAILTO= in cron to get email which might have more details if something is failing when cron is run.
I resolved this by removing cron from the equation. page was of great help.
The below is the jupyter.service file I had to create at /etc/systemd/system.
[Unit]
Description=Jupyter Workplace
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=<path_to>/jupyter-notebook --config=<path_to>/jupyter_notebook_config.py
User=<username>
Group=<groupname>
WorkingDirectory=<start up path where notebooks are>
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetThen run the following:
systemctl enable jupyter.service
systemctl daemon-reload
systemctl restart jupyter.serviceThank you everyone.