Run python script as scheduled task in Synology
So if the python script does not need additional libraries other than the standard ones installed with the Python3 package, it should be simpler process:
- On package center, install python 3 package from Synology Inc.
- Go to Control Panel-> Scheduled Task, add a new one, and in the command, put on something like
/usr/local/bin/python3 <path/to/the/py/file>
However, in my case, I need to install a third party library, and I’d like a normal user to run it. So here are the addition steps:
3. ssh with admin (as non-admin user cannot ssh)
4. install pip:
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
Note you have to sudo so the pip module can be installed into the site location shared by all users.
5. install the 3rd party library using pip:
sudo python3 -m pip install blinkpy
Phew~
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
After a recent update of Synology DSM, it seems the python site-packages folder can only be accessed by the owner “root” after installing the packages. To fix that, I have to grant those access in a ssh shell by:
cd /usr/lib/python3.8/site-packages/
sudo find . -type d -exec chmod a+x {} +
sudo chmod -R a+r *