0

I have a Cron job that runs every 10 min on Linux (Ubuntu) machine.

*/10 * * * * /home/dbase/Salesforce/InsertJob1

When I did grep CRON /var/log/syslog, it displays all the records of this Cron job (InsertJob1) that has been run every 10 min.

But, when I looked at the results at the database side (Salesforce), nothing has been performed (no insertions).

On the destination side (Salesforce database), I do not see any login history of this SOAP API.

But, when I execute this Python file manually using IDE (PyCharm), it runs fine, and data gets inserted into the Salesforce database.

My questions are:

  1. Do I have to modify the crontab so that it shows as InsertJob1 instead of InsertJob1.py?

  2. Do I have to create a link instead of leaving the file as InsertJob1.py or without extension like InsertJob1?

  3. What other task(s) do I have beside leaving the Python file at the folder location where I pointed on Cron?

  • 1
    I'm not sure I fully understand your question and I don't use Python yet. Buti n general cron requires you to always put in the full path to the command and include the extension as well. – WinEunuuchs2Unix Aug 8 '17 at 4:14
0

You have a mistake in your cron:

*/10 * * * * /home/dbase/Salesforce/InsertJob1

should be

*/10 * * * * /path/to/env/bin/python /home/dbase/Salesforce/InsertJob1.py

When you run code from the terminal in a virtual environment (if you're not using one, you should consider it), you run it as

python script.py

The cron runs in much the same way, except you should specify a path to your python executable that has the appropriate packages installed.

In general, while logging for a cron job, you should have some output written to the log files that tell you whether the appropriate parts of your cron have run or not. Just add a few print() at the right places, or use the python logging module for your script.

  • Are you saying I should just add .py extension to current line? or I should add "/path/to/bin/python" along with what I have and .py extension? I have other previous cron task (Python files) that are working fine withtout .py extension. – Java Aug 11 '17 at 17:14

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.