Running a python code periodically

Amitabh Saikia saikia at unspokenmind.net
Thu May 8 16:42:17 EDT 2008


Cron is best for this, and you should be able to create a crontab for
yourself. If your system admin has not enabled user level crons. Then
write a shell-script or python

Shell version
-----------------
count=0
max_number_of_times
while [ $count < $max_number_of_times ];
do
  your_command &
  sleep <time_interval>
  count=`expr $count + 1`
done

I said about nohup, in case you want to logout and still want this to work.
You can also use `screen' (only in the case where you are planning to logout
and you want your program should run).

- saikia

--


On Thu, May 8, 2008 at 9:12 AM, Maryam Saeedi <ma.saeedi at gmail.com> wrote:

> Can you please explain it a little more? I do not have that much
> experience! I really appreciate it if you can share a sample code if you
> have one.
>
> Thanks
>
> On Thu, May 8, 2008 at 11:07 AM, Amitabh Saikia <saikia at unspokenmind.net>
> wrote:
>
>> write a bash script(to run your program at intervals) and run the bash
>> script with nohup
>>
>> - saikia at unspokenmind.net
>>
>> On Thu, May 8, 2008 at 9:02 AM, Maryam Saeedi <ma.saeedi at gmail.com>
>> wrote:
>>
>>> I was wondering if you know how can I run a python code once every five
>>> minutes for a period of time either using python or some other program like
>>> a bash script.
>>>
>>> I have asked this question before and some of you answered me but I still
>>> have problem. Most of the answers was to use cron and crontab which works on
>>> my computer but not if I want to do it on department's computer since I do
>>> not have permission to change those files. Is there any other way which does
>>> not need administrator permission?
>>>
>>> Thanks  a lot,
>>>
>>> Maryam
>>>
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
>
>
> --
> Maryam Saeedi
> PhD student
> Economics Department
> University of Minnesota
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080508/17a026c7/attachment.html>


More information about the Python-list mailing list