Page MenuHomePhabricator

Issue with running jobs using cron
Closed, ResolvedPublic


I have recently uploaded a tool named mlwikidbupdate in WMFLabs. It was forked from this code. The code works fine when I use the command:


When converting this into a running job, job I submitted was:

*/1 * * * * /usr/bin/jsub -N tools.mlwikidbupdate -once python /mnt/nfs/labstore-secondary-tools-project/mlwikidbupdate/

This is not working and generates the error:

Traceback (most recent call last):
  File "/mnt/nfs/labstore-secondary-tools-project/mlwikidbupdate/", line 7, in <module>
    import wikitools
ImportError: No module named wikitools

I have imported Python as well as wikitools many times, but the problem still remain.

Event Timeline

Aklapper changed the task status from Open to Stalled.Jun 4 2020, 7:30 AM

Hi @Adithyak1997, there is no "WMFLabs"... Can you please provide context where to find your tool? Where is its source code? Please read and follow when creating tickets here - thanks!

Link for my tool. It doesn't have a UI and updations are done with the help of WinSCP and Putty.

In WinSCP, the location of my tool (alongwith it's source code) is present in the location /mnt/nfs/labstore-secondary-tools-project/mlwikidbupdate

The python command may be pointing to a different location depending on where it is being run from. Try to put the full path to python on cron jobs may expect to be run on the same folder where it is. This is not the case when running from cron job. Fix the script, or change to that directory before executing it:

What is wikitools, and where exactly is wikitools located on your system?

This is the folder structure where Wikitools is located.

The issue is fixed by adding the path of Python. The actual cron job required was:

*/2 * * * * /usr/bin/jsub -N tools.mlwikidbupdate -once /mnt/nfs/labstore-secondary-tools-project/mlwikidbupdate/venv/bin/python /mnt/nfs/labstore-secondary-tools-project/mlwikidbupdate/
Adithyak1997 claimed this task.