How to add a cron job inside setup.py using the post installation commands (the cmdclass parameter).
The cron job will use the newly installed library to call a specific function from the library.
Asked
Active
Viewed 268 times
1 Answers
0
Your question is really vague, but you could do it if you wrote out a temp script somewhere to import said library and do whatever things you require, then write out a crontab to run a command such as:
py -<python version> <python script>
Some additional Python-specific info on cron jobs can be found in this question which may be good to read, just in case.
To actually DO this, you'd add something like this to your setup.py:
from setuptools import setup
from setuptools.command.install import install
class PostInstallCommand(install):
def run(self):
# PUT YOUR POST-INSTALL SCRIPT HERE or CALL A FUNCTION
install.run(self)
You'd also need to add this to your setup() func:
setup(
...
cmdclass={
'install': PostInstallCommand,
},
...
)

Parzival Wolfram
- 21
- 5
-
But how do I add this to the post installation script in setup.py? This is my main issue – Drxxd Nov 20 '18 at 13:30
-
@Drxxd will fix, one second – Parzival Wolfram Nov 20 '18 at 13:33
-
@Drxxd done, sorry. I got distracted, so I pushed the incomplete answer. – Parzival Wolfram Nov 20 '18 at 13:38
-
I'm using the "PostInstallCommand" already. The main thing is how to add a cron job inside the runner (When the cron job will be a command that uses the newly installed library) – Drxxd Nov 20 '18 at 13:41
-
I'd need more info on the library and command to be able to tell you that (as i'd basically have to do it for you) – Parzival Wolfram Nov 22 '18 at 02:25