On 15/04/13 19:23, Zaki Akhmad wrote:
On Mon, Apr 15, 2013 at 3:51 PM, Alan Gauld <[email protected]> wrote:
multiple cron jobs will be less work for your computer than running a long
term program constantly checking times and launching your scripts... That's
called reinventing the wheel with a square one...
There are more modern (and more efficent) replacements for cron but given
your requirements cron still looks like the best bet.
Actually,
I want to write a twitter bot which runs on a specific time.
That is exactly what cron is designed to do. Although given that the time you want will
vary, my guess is that the lesser-known "at" job will be better.
Another option is the sched module, that lets you schedule tasks to run while
your program is idling. It is not a replacement for cron or at, since it
requires your program to be running. But for simple needs, it may do the job.
http://docs.python.org/2/library/sched.html
http://pymotw.com/2/sched/
For an
idea, I'd like to have this twitter bot tweet every sunrise and
sunset, everyday. Since everyday the sunrise and the sunset time are
vary, what are the best way to do it?
Sunrise and sunset *where*?
Because the world is a globe, sunrise and sunset vary from place to place. Even in one
place, they also vary at different times of the year. If you google for "sunrise
sunset algorithm", you may find a formula for calculating the time of each at a
given latitude and longitude. Or not. I don't really know how complicated it is.
Should I entered the sunset and the sunrise manually?
I don't know about "manually", but there's no standard Python command for
giving you sunset and sunrise. You'll either need to find an existing program that does
it, or write one yourself.
--
Steven
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor