I have a python file which is created on windows which is also working on ubuntu OS aswell. I have a VPS in hostinger platform where this script should run in daily basis. But triggers on the scheduled period is not happening.
I have created a Cronjob using the command
crontab -e
the Cron syntax used:
* 12 * * * python filpath/script.py
but the file is not getting executed. I have checked the system logs their is nothing related to cron jobs. Am not sure where things went wrong.
2
Answers
Try this line in cron tab:
You incorrectly assume working directory will be the same for cronjob that is for your current session in i.e. shell. It will not. You need to change that in cron or use absolute path to your script. The former sounds better for me as I assume your scripts might have troubles working properly otherwise:
assuming your
script.py
lives infilpath
folder located in<PATH/TO/YOUR/PROJECT>
.You stil can have the same problem with
python
itself, but it’s more likely that it will be inPATH
cron uses (you can change that to absolute path). BTW: when cron job fails, then you (I mean the user on which account the cron is running) shall receive a system mail with more detailed error. So check that too if you can access it.