1

I'm having a bit of problem with my cron job on my RaspberryPi.

It's a python script requesting json data from a bitcoin exchange, and packing them into a tarball.

When executing the script from CLI it works fine, files are created and the logging module writes to the designated logfile.

My cronjob, however, somehow misses out on that. There's no logs written by my script, and the output i'm dumping to a file only reads None (indicating that there isn't anything outputted by my script).

This leads me to believe that the script isn't executed at all, albeit the cronjob itself does run.

My crontab for user kraken line looks like this:

*/5 * * * *    /usr/bin/python3 /mnt/crawler/bots/btce_bot.py >> /mnt/crawler/bots/bots.log

The same command, i.e. /usr/bin/python3 /mnt/crawler/bots/btce_bot.py, executed from CLI gives me a log containing all the expected data (all url's requested and data received successfully, along with a print() to console of the api credentials)

I've chmodded my script and all files it requires (it loads urls from seperate .api files) to 700.

-rwx------ 1 kraken kraken   1934 Dec  7 18:54 apiHandler.py
-rwx------ 1 kraken kraken    202 Dec  7 18:54 Bitstamp.api
-rw-r--r-- 1 kraken kraken 476089 Dec  9 20:16 btce_bot.log
-rwx------ 1 kraken kraken   1983 Dec  9 20:15 btce_bot.py
-rwx------ 1 kraken kraken    411 Dec  7 18:54 CEX.api
-rwx------ 1 kraken kraken   1973 Dec  7 20:17 jsonHandler.py
-rwx------ 1 kraken kraken    231 Dec  7 18:54 Kraken.api
drwxr-xr-x 2 kraken kraken   4096 Dec  7 20:22 __pycache__

The directory is chmod 755'd.

4 drwxr-xr-x 3 kraken kraken 4096 Dec  9 20:16 bots #Scripts in here
4 drwxr-xr-x 2 kraken kraken 4096 Dec  9 20:16 data #Dumps tarballs in here

I realize there have been several questions across a multitude of forums on the web; i've tried any solutions I found but to no avail.

Hence, I'm suspecting it may be a raspbian-based issue? Is there something else that might stop my scripts from running?

  • what happens if you run /usr/bin/python3 /mnt/crawler/bots/btce_bot.py without appending to the log? Who owns the /mnt/crawler/bots directory and what are the permissions for the directory, script and log file? – Steve Robillard Dec 9 '15 at 20:42
  • ..I've added the permissions in the question - read/write/execute for all files in the bots folder; the bots folder is owned by user kraken. Chmod 755 on those folders. Without appending to log yields more of the same - just without the log file. – j4ck Dec 9 '15 at 20:47
  • Have you tried putting the command in a file and then calling the file? – Steve Robillard Dec 9 '15 at 20:48
  • 3
    Then asking for clarification on how to fix it would've been far better imo then a straight deletion of my answer (while I was typing a clarification). That, I find incredibly rude as well as the straight out dismissal without trying by the OP. – Diederik de Haas Dec 9 '15 at 22:23
  • 1
    @DiederikdeHaas I did not delete your answer. I converted it to a comment which is what it was. I also, did it to give you and the OP a little space to cool down, as the tone of the conversation was becoming argumentative. I have restored your answer/comment. Please complete the answer with the relevant details. – Steve Robillard Dec 10 '15 at 9:41
3

It turns out the script was being executed afterall; The library I'm using passes relative paths(i.e. ./path/to/file) by default, which does not sit well with cron jobs, apparently.

I have edited my code to use absolute paths ( i.e. /full/path/to/file) and it runs smoothly now.

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.