public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Joseph <syscon780@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] crontab - "and' condition
Date: Sat, 20 Sep 2014 11:40:22 -0600	[thread overview]
Message-ID: <20140920174022.GA4334@syscon7> (raw)
In-Reply-To: <541BDF9B.7080204@gmail.com>

On 09/19/14 09:47, Stephan Müller wrote:
>Am 18.09.2014 um 18:44 schrieb Joseph:
>> I want to run a cron job only once a month.  The problem is the computer is only on on weekdays Mon-Fri. 1-5
>> cron tab as this below is an "or" condition as it has entries in Days of the Months and Day of the  Week
>>
>> 5 18 1 * 2  rsync -av ...
>>
>> so it will run on days 1 or Tuesday of each months.
>> Is it possible to create "and" condition, eg. run it on Tuesday between days 1 to 7; depend on which day Tuesday falls on?
>
>You can run it every Tuesday and check for day of month externally:
>
>5 18 * * 2   test $(date +%d) -le 7 && rsync -av ...
>
>or run it on
>
>5 18 1-7 * * and test for Tuesdays, but the former gives less useless invocations.
>
> ~frukto

Thanks, very cleaver, I knew there must be a solution.

-- 
Joseph


      reply	other threads:[~2014-09-20 17:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18 16:44 [gentoo-user] crontab - "and' condition Joseph
2014-09-18 16:57 ` Kerin Millar
2014-09-18 17:14 ` Alan McKinnon
2014-09-19  4:21   ` Joseph
2014-09-19  7:09     ` Alan McKinnon
2014-09-20 16:09       ` Michael Orlitzky
2014-09-21  7:57         ` Peter Humphrey
2014-09-19  7:47 ` Stephan Müller
2014-09-20 17:40   ` Joseph [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140920174022.GA4334@syscon7 \
    --to=syscon780@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox