Question

Let me start out by saying I'm extremely new to using python and creating a crontab.

Basically have a custom Python environment created on my dreamhost account using this tutorial http://wiki.dreamhost.com/Python#Automatic_Installation Running python script is easy after this. Normally I just type this whenever I have a new session.

source /home/emre801/.bashrc

pb switch 2.7.3

Then I just run any python script using this

pb py code.py

The issue is when I try to create a crontab, I have this right now in my crontab.

*/10 * * * * source /home/emre801/.bashrc; pb switch 2.7.3;pb py code.py 

This code emails me the following output

/bin/sh: pb: command not found

My question is how can I set it up the source correctly to not give me this error?

Any help is greatly appreciated

Was it helpful?

Solution

Just create a bash script for this:

/home/emre801/run.sh

#!/bin/bash

source /home/emre801/.bashrc
pb switch 2.7.3
pb /full/path/to/your/code.py

make it executable:

$ chmod 755 /home/emre801/run.sh

And add it to the crontab:

*/10 * * * * /home/emre801/run.sh

or

*/10 * * * * bash /home/emre801/run.sh
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top