Using cron to run a python script

 
Post new topic   Reply to topic    34SP.com Forum Index // Scripting Support
View previous topic :: View next topic  
Author Message
AdamDynamic
34SP Newbie
34SP Newbie


Joined: 11 Jul 2013
Posts: 3

PostPosted: Mon Jul 22, 2013 10:29 pm    Post subject: Using cron to run a python script Reply with quote
Hi,

I'm completely new to cron (and fairly new to python) so I thought I would ask here before setting anything off (particularly as the cron page on my pro host account desktop says only to use the cron page if you have 'experience')

I have a python script that I have saved in my cgi-bin folder on my professional hosting account. I want to run it every 15 mins. As far as I can tell, the following should be correct:

*/15 * * * * /usr/local/bin/MyPythonScript.py

Can anyone confirm my understanding before I start playing around with the actual settings? In particular, the examples I've found on the 34sp.com site talk about the Lynx browser? I've no idea why though?

Any assistance would be appreciated!

Thanks,

Adam
Back to top
View user's profile Send private message
philr
Super Member
Super Member


Joined: 05 Nov 2003
Posts: 990
Location: Exeter

PostPosted: Wed Jul 24, 2013 9:06 am    Post subject: Reply with quote
To run a python script from the command line, you type in the location of the python interpreter, followed by a space, then by the location of the script you want to run.

You have to use the same syntax in cron tasks. Depending on where things are situated on your server, you probably need to use something like this:

*/15 * * * * /usr/local/bin/python /usr/local/psa/home/vhosts/your-domain-here/cgi-bin/MyPythonScript.py
_________________
Phil Ronan
フィリップ・ローナン
Back to top
View user's profile Send private message Visit poster's website
AdamDynamic
34SP Newbie
34SP Newbie


Joined: 11 Jul 2013
Posts: 3

PostPosted: Mon Jul 29, 2013 7:04 am    Post subject: Reply with quote
philr wrote:
To run a python script from the command line, you type in the location of the python interpreter, followed by a space, then by the location of the script you want to run.

You have to use the same syntax in cron tasks. Depending on where things are situated on your server, you probably need to use something like this:

*/15 * * * * /usr/local/bin/python /usr/local/psa/home/vhosts/your-domain-here/cgi-bin/MyPythonScript.py


Thanks for the reply, so this would be correct?:

*/15 * * * * /usr/local/bin/python /usr/local/psa/home/vhosts/www.mydomain.com/cgi-bin/MyPythonScript.py

Can any of the 34sp.com staff tell me whether the file path is correct for the server I'm on?

Thanks again,

Adam
Back to top
View user's profile Send private message
Post new topic   Reply to topic    34SP.com Forum Index // Scripting Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Powered by phpBB © 2001, 2002 phpBB Group