From nobody Sun Sep 18 16:55:41 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 4MVv886zNCz4cv37 for ; Sun, 18 Sep 2022 16:55:52 +0000 (UTC) (envelope-from andreas.kahari@abc.se) Received: from hekla.abc.se (hekla.abc.se [158.174.61.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4MVv874D4yz3bRF for ; Sun, 18 Sep 2022 16:55:51 +0000 (UTC) (envelope-from andreas.kahari@abc.se) Received: from harpo.local (83-233-37-250.cust.bredband2.com [83.233.37.250]) by hekla.abc.se (OpenSMTPD) with ESMTPSA id 94d1dcf8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 18 Sep 2022 18:55:43 +0200 (CEST) Date: Sun, 18 Sep 2022 18:55:41 +0200 From: Kusalananda =?utf-8?B?S8OkaMOkcmk=?= To: paul beard Cc: FreeBSD-questions Subject: Re: command works interactively but not in cron? Message-ID: Mail-Followup-To: paul beard , FreeBSD-questions References: 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 4MVv874D4yz3bRF X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of andreas.kahari@abc.se designates 158.174.61.227 as permitted sender) smtp.mailfrom=andreas.kahari@abc.se X-Spamd-Result: default: False [-1.29 / 15.00]; R_MIXED_CHARSET(1.00)[subject]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.999]; NEURAL_HAM_LONG(-1.00)[-0.998]; NEURAL_HAM_MEDIUM(-0.99)[-0.993]; R_SPF_ALLOW(-0.20)[+ip4:158.174.61.227]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8473, ipnet:158.174.0.0/16, country:SE]; MIME_TRACE(0.00)[0:+]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; TO_DN_ALL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; DMARC_NA(0.00)[abc.se]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N On Sun, Sep 18, 2022 at 08:49:05AM -0700, paul beard wrote: > /usr/sbin/pkg query %o works fine interactively but if I use it to backup a > list of installed pkgs in crontab, it fails: > > 00 4 * * * /usr/sbin/pkg query %o > /var/backups/installed.pkgs > > Usage: pkg query > pkg query [-a] > pkg query -F > pkg query -e > pkg query [-Cgix] <...> > > For more information see 'pkg help query.' > > What am I missing here? > -- > Paul Beard / www.paulbeard.org/ Escape the % 0 4 * * * /usr/sbin/pkg query \%o >/var/backups/installed.pkgs See also crontab(5) -- Andreas (Kusalananda) Kähäri SciLifeLab, NBIS, ICM Uppsala University, Sweden .