From nobody Mon Mar 7 14:14:54 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 236EE1A03586 for ; Mon, 7 Mar 2022 14:15:11 +0000 (UTC) (envelope-from 4250.82.1d4db00031b8add.f9ed44372021f9addb55d8066321a450@email-od.com) Received: from s1-b0c6.socketlabs.email-od.com (s1-b0c6.socketlabs.email-od.com [142.0.176.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4KC0pk2Y1Hz3Gg6 for ; Mon, 7 Mar 2022 14:15:10 +0000 (UTC) (envelope-from 4250.82.1d4db00031b8add.f9ed44372021f9addb55d8066321a450@email-od.com) DKIM-Signature: v=1; a=rsa-sha256; d=email-od.com;i=@email-od.com;s=dkim; c=relaxed/relaxed; q=dns/txt; t=1646662510; x=1649254510; h=content-transfer-encoding:content-type:mime-version:references:in-reply-to:message-id:subject:cc:to:from:date:x-thread-info:subject:to:from:cc:reply-to; bh=RxUZfU24qU+iexGvB5mmpa3g8GHTOX6TBAu4iogLE04=; b=u3fG6MKw7hmSaTMZ+gxl81LpRrwU3B/KSG0ssRNTcjnAlZQvi/bF6GYZ8GqJvvSo//T23e7XCUzVi3BmaIS82plYN2ffcApb1wD6MrI4D3QHInKRnMITacXjUxJ9iXJSn+s43Ke5f0G9gwn63RXjxT2v0NypPoYaAZuzmb1yJqM= X-Thread-Info: NDI1MC4xMi4xZDRkYjAwMDMxYjhhZGQuZnJlZWJzZC1xdWVzdGlvbnM9ZnJlZWJzZC5vcmc= Received: from r3.us-east-2.aws.in.socketlabs.com (r3.us-east-2.aws.in.socketlabs.com [142.0.189.3]) by mxsg2.email-od.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Mon, 7 Mar 2022 09:14:57 -0500 Received: from smtp.lan.sohara.org (EMTPY [185.202.17.215]) by r3.us-east-2.aws.in.socketlabs.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Mon, 7 Mar 2022 09:14:56 -0500 Received: from [192.168.63.1] (helo=steve.lan.sohara.org) by smtp.lan.sohara.org with smtp (Exim 4.94.2 (FreeBSD)) (envelope-from ) id 1nRE8U-000DMd-Ro; Mon, 07 Mar 2022 14:14:54 +0000 Date: Mon, 7 Mar 2022 14:14:54 +0000 From: Steve O'Hara-Smith To: Jos Chrispijn Cc: FreeBSD Mailing List Subject: Re: Crontab | random execution time Message-Id: <20220307141454.91255883d98dd7b980e6fc22@sohara.org> In-Reply-To: <9e16ee69-3793-41f5-385f-71d87dedcf2c@cloudzeeland.nl> References: <9e16ee69-3793-41f5-385f-71d87dedcf2c@cloudzeeland.nl> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd13.0) X-Clacks-Overhead: "GNU Terry Pratchett" List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4KC0pk2Y1Hz3Gg6 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=email-od.com header.s=dkim header.b=u3fG6MKw; dmarc=none; spf=pass (mx1.freebsd.org: domain of 4250.82.1d4db00031b8add.f9ed44372021f9addb55d8066321a450@email-od.com designates 142.0.176.198 as permitted sender) smtp.mailfrom=4250.82.1d4db00031b8add.f9ed44372021f9addb55d8066321a450@email-od.com X-Spamd-Result: default: False [-0.94 / 15.00]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[email-od.com:s=dkim]; FROM_HAS_DN(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:142.0.176.0/20]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sohara.org]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_SPAM_MEDIUM(0.76)[0.755]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[email-od.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[142.0.189.3:received]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-questions]; FORGED_SENDER(0.30)[steve@sohara.org,4250.82.1d4db00031b8add.f9ed44372021f9addb55d8066321a450@email-od.com]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:7381, ipnet:142.0.176.0/22, country:US]; FROM_NEQ_ENVFROM(0.00)[steve@sohara.org,4250.82.1d4db00031b8add.f9ed44372021f9addb55d8066321a450@email-od.com]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[email-od.com:dkim] X-ThisMailContainsUnwantedMimeParts: N On Mon, 7 Mar 2022 14:36:19 +0100 Jos Chrispijn wrote: > Dear list, > I am trying to run a cron job, starting once every two hours and at > random minute  in the half our of that cron scheme: > > SHELL=/bin/sh > PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/etc > 0~30   */2     *       *       *       root /root/cronjobs/run_myjob > > Unfortunately it is running exactly on the hour instead of random > between 0-30 minutes. I'd expect that to run once a minute for the first thirty minutes of even numbered hours. The usual way to achieve what you want is to add a random sleep in front of the job, or just rely on cron's jitter feature which isn't usually set for that much spread and affects every job. -- Steve O'Hara-Smith