I would like to know how can I determine if a python script is executed from crontab?
I don't want a solution that will require adding a parameter because I want to be able to detect this even from an imported module (not the main script).
Set an environment variable at the cron command invocation. That works even within a module, as you can just check os.getenv().
How can I determine if a python script is executed from crontab?