From: Alan McKinnon <alan.mckinnon@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Using date/time variables in cronjobs?
Date: Sun, 05 May 2013 19:49:25 +0200 [thread overview]
Message-ID: <51869BA5.9030206@gmail.com> (raw)
In-Reply-To: <51868F41.6050407@libertytrek.org>
On 05/05/2013 18:56, Tanstaafl wrote:
> Ok, another little thing...
>
> Is there a simple way to use date/time variables in cronjobs? Or do I
> need to use a bash script for this? I prefer simple, and just using the
> variables directly in the cron command would be easier if it works, so
> figured I'd ask first...
>
> I'm trying to schedule a dump of my databases like so:
>
> pg_dumpall --username=username -o -f
> /home/user/mypg_backups/hourly/\%y/\%m/\%d/\%t.sql.gz
>
> But trying to run this command fails with:
>
> pg_dumpall: could not open the output file
> "/home/user/mypg_backups/hourly/%y/%m/%d/%t.sql.gz": No such file or
> directory
>
> Tried escaping the variables and not, same error...
What creates those variables %y etc? They don't "just exist", something
sets them. Check that that thing sets them correctly.
But I'll bet the directory /home/user/mypg_backups/hourly/\%y/\%m/\%d/
doesn't exist. pg_dumpall won;t create it, that's your job.
So now you need a test that the directory exists, mkdir -p it if not,
and only then write the output file. Which is far easier done in a
wrapper script than in a one-liner, if only for the fact that you have
indented text.
Sometimes, making things simpler makes your life harder. This looks like
such a case.
--
Alan McKinnon
alan.mckinnon@gmail.com
next prev parent reply other threads:[~2013-05-05 17:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-05 16:56 [gentoo-user] Using date/time variables in cronjobs? Tanstaafl
2013-05-05 17:07 ` Mick
2013-05-05 17:32 ` Tanstaafl
2013-05-05 17:49 ` Alan McKinnon [this message]
2013-05-05 18:07 ` Tanstaafl
2013-05-05 18:18 ` Neil Bothwick
2013-05-05 18:31 ` Tanstaafl
2013-05-05 20:06 ` Todd Goodman
2013-05-05 21:25 ` Neil Bothwick
2013-05-05 21:56 ` Tanstaafl
2013-05-05 23:21 ` Tanstaafl
2013-05-06 0:09 ` Volker Armin Hemmann
2013-05-06 9:48 ` Neil Bothwick
2013-05-06 3:25 ` Pandu Poluan
2013-05-11 16:51 ` SOLVED - WAS " Tanstaafl
2013-05-05 20:17 ` Alan McKinnon
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=51869BA5.9030206@gmail.com \
--to=alan.mckinnon@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