Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82635
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <juan0christian@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'else:': 0.03; 'indeed,': 0.09; 'subject:script': 0.09; 'random': 0.14; '(ubuntu': 0.16; '1),': 0.16; 'execute,': 0.16; 'redo': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'true:': 0.16; 'wrote:': 0.18; 'code.': 0.18; '<': 0.19; 'thanks.': 0.20; 'email addr:gmail.com>': 0.22; 'script': 0.25; 'least': 0.26; 'to:2**1': 0.27; 'fixed': 0.29; "doesn't": 0.30; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'container': 0.31; 'workaround': 0.31; 'stuff': 0.32; 'run': 0.32; 'another': 0.32; 'running': 0.33; "i'd": 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; "didn't": 0.36; "i'll": 0.36; 'subject:?': 0.36; 'christian': 0.38; 'server': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'simple': 0.61; 'times': 0.62; 'great': 0.65; 'hours': 0.66; 'answer.': 0.68; 'subject:there': 0.68; 'hour,': 0.84; 'min': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:from:date:message-id:subject:to :content-type; bh=ObQ+jKwNaqzkdtht1BJnQ01RLnL6j/MibJabdCutSvA=; b=fJEsIuTbun8Sj7zuGzWzm1PMCsSH6OaexhDv80Oog/69kU7g0jZ5977XAYrq+9WKdZ wLnbrjfMhRf3fe8kymPxKe/KH9XgfUxs78LHYHJtHh1W0QD+yJETewrli835Ael8mOmu B23eS00FOk6pe0VrZLjxDH79HwW0PtALa0nQlJchwXRT1uTZx4QZnMv8bLSPeHOgE7cY MiDOs0Lf7waTaQu2ee8qkK3xEMtX0kQpfdJ+QTEezsn2gW2+O1+tIc8U/DvXFeWkTVzt Y/Bbr4qcyP6eapPGNy9MRmQ3IC6VsUBYowICaMUjjB3Iwf+AliHpxv+KkYTCdGjj1Rkw wUIw== |
| X-Received | by 10.50.82.66 with SMTP id g2mr13151477igy.19.1418906271515; Thu, 18 Dec 2014 04:37:51 -0800 (PST) |
| MIME-Version | 1.0 |
| References | <mailman.17010.1418843457.18130.python-list@python.org> <54921444$0$12995$c3e8da3$5496439d@news.astraweb.com> <CAAp0bGv4cwqUJ2Gi1ROJB=_HhBDbeSEqOWpJX3x0CtyZkXULcQ@mail.gmail.com> |
| From | Juan Christian <juan0christian@gmail.com> |
| Date | Thu, 18 Dec 2014 12:37:50 +0000 |
| Subject | Re: Is there a way to schedule my script? |
| To | "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>, python-list@python.org |
| Content-Type | multipart/alternative; boundary=089e0111b848488d99050a7cdcd3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17030.1418906581.18130.python-list@python.org> (permalink) |
| Lines | 58 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1418906581 news.xs4all.nl 2876 [2001:888:2000:d::a6]:52867 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 6208 |
| X-Received-Body-CRC | 740098976 |
| Xref | csiph.com comp.lang.python:82635 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Wed Dec 17 2014 at 11:04:16 PM Juan Christian <juan0christian@gmail.com> wrote: Thanks. That was a great answer. I'll redo my code. It's running and will only run in my Docker container (Ubuntu Server 14.04.1) so I'll use cron. Indeed, currently I'm using something like that: while True: if 9 < datetime.now().hour < 24: # do stuff sleep(randint(3, 6) * 60) else: # see you in 9 hours sleep(9 * 60 * 60) I knew it wasn't a good approach, but as least it was running as intended! I read the cron doc, it's really simple to use, but one think I didn't see out-of-the-box is a way to set a random time, like 'execute this in a 5~10 min interval', I can only set specific times like 'execute this each minute, each hour, each 10min' and so on. I found a 'fix' for that using $RANDOM in the crontab. Another workaround would be to set a fixed 5min interval in cron and inside my script have a random int (0 or 1), when 0, the script doesn't execute and 1 it execute, so that way I'd have a little 'randomness' that I need. Which approach would be the best?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-17 19:10 +0000
Re: Is there a way to schedule my script? John Gordon <gordon@panix.com> - 2014-12-17 19:41 +0000
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-17 19:51 +0000
Re: Is there a way to schedule my script? John Gordon <gordon@panix.com> - 2014-12-17 20:23 +0000
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-17 20:42 +0000
Re: Is there a way to schedule my script? Chris Angelico <rosuav@gmail.com> - 2014-12-18 08:34 +1100
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-17 21:47 +0000
Re: Is there a way to schedule my script? Michael Torrie <torriem@gmail.com> - 2014-12-18 09:45 -0700
Re: Is there a way to schedule my script? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-18 10:39 +1100
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-18 01:04 +0000
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-18 12:37 +0000
Re: Is there a way to schedule my script? Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-18 09:23 -0700
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-18 22:13 +0000
Re: Is there a way to schedule my script? Chris Angelico <rosuav@gmail.com> - 2014-12-19 12:32 +1100
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-19 01:55 +0000
Re: Is there a way to schedule my script? Terry Reedy <tjreedy@udel.edu> - 2014-12-19 00:58 -0500
Re: Is there a way to schedule my script? Josh English <Joshua.R.English@gmail.com> - 2014-12-18 09:13 -0800
Re: Is there a way to schedule my script? Juan Christian <juan0christian@gmail.com> - 2014-12-18 18:29 +0000
csiph-web