Re: command works interactively but not in cron?

From: Kusalananda Kähäri <andreas.kahari_at_abc.se>
Date: Sun, 18 Sep 2022 16:55:41 UTC
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 <query-format> <pkg-name>
>        pkg query [-a] <query-format>
>        pkg query -F <pkg-name> <query-format>
>        pkg query -e <evaluation> <query-format>
>        pkg query [-Cgix] <query-format> <pattern> <...>
> 
> 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

.