0

I have a Python package which provides a console executable airship which I would like to run on a regular basis using cron. However, when I add a line to my crontab that should do this, the script never executes. I have a way of telling when my script is being executed (my Steam status shows me as playing a specific game). This is the result of crontab -l:

*/2 * * * * /usr/bin/env airship

(The 2 is just for testing purposes, ideally it would be 15).

What is stopping this from happening?

Carlos Liam
  • 305
  • 2
  • 10
  • is it installed on path? if you run airship from an arbitrary folder, does it work? – John Jun 03 '15 at 22:41
  • I ran it from `/` and it worked fine. So yes, it's on `$PATH`. – Carlos Liam Jun 04 '15 at 20:07
  • Chances are it has permissions issues and cannot be run from system process as it doesn't have access to some resource. Try this: http://stackoverflow.com/questions/8475694/how-to-specify-in-crontab-by-what-user-to-run-script – John Jun 04 '15 at 20:17
  • The crontab in question is not for the root user, so I don't think this is the problem. (I verified this with `sudo crontab -u aarzee -l`, my user is aarzee). – Carlos Liam Jun 04 '15 at 21:47
  • Have you tried something simple like checking if echo hello > file.txt executes? – John Jun 04 '15 at 21:51
  • I have now, and it does work. https://ghostbin.com/paste/rfdyu – Carlos Liam Jun 04 '15 at 22:13
  • Now, I'd suppose you should do the same with airship - pip the output to a file. – John Jun 04 '15 at 22:14
  • I've done this, but the file that is created is empty (it does exist though). – Carlos Liam Jun 04 '15 at 22:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/79710/discussion-between-carlos-liam-and-john). – Carlos Liam Jun 04 '15 at 22:44

1 Answers1

0

From this answer which helped me with the same problem.

It's possible that crontab doesn't locate python interpreter. So which python locates your python, for example /usr/local/bin/python

Locate your app which airship for example /usr/local/bin/airship

So crontab should be something like:

* * * * * /usr/local/bin/python /usr/local/bin/airship

Maybe package has some other problems, check it with environment used by crontab: env -i /bin/bash --noprofile --norc and then run your script.

Rasul
  • 121
  • 2
  • 3
  • 7