0

I created a Python command that uploads a zip file to an FTP server

I want to run it every 5 minutes using cron jobs.

So I opened crontab using crontab -e and I added the following line

enter image description here

The cron job does not work but when I run smart-cv.py archive from the terminal it works and I can see that the zip file is uploaded to the FTP server.

I have already tried restarting the cron server with service cron restart but it does not work

  • 1
    Welcome to Ask Ubuntu! Please do not post screenshots of the terminal. Paste the text directly to your question and apply code formatting. – Melebius May 27 at 6:15
  • 1
    A general tip to debug cronjobs is to send the full output to a log file, like */5 * * * * smart-cv.py archive >> /tmp/user-crontab.log 2>&1, then open another console and run tail -f /tmp/user-crontab.log to see the output live while it runs. You can change the path of the log file to your home folder. – bistoco May 27 at 8:05
4

Give the complete path of the python file. Change your command to

 5 * * * * /path-of-the-file/smart-cv.py archive 

Hope it helps.

  • The Python command that I created belongs to a custom module that I deployed. It's located in /usr/local/lib/python3.6/dist-packages/smart_cv-1.0.0-py3.6.egg/EGG-INFO/scripts. When I run smart-cv.py archive the terminal automatically searchs in the path so how can i tell cron to do the same ? – Amine Messaoudi May 24 at 12:14
  • You can add a PATH=$PATH:xxx assignment at the top of your crontab (actually anywhere before the command) – steeldriver May 24 at 12:29
  • @AmineMessaoudi Please edit your question to reflect all the details you posted in the comment. It helps to keep our Q&A style tidy and could also bring more attention since an edited question gets bounced on the homepage. – Melebius May 27 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.