* crontab: how to put date in archive filename?
@ 1999-09-26 4:00 Steve Stoddard
1999-09-27 4:00 ` Emile van Bergen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Steve Stoddard @ 1999-09-26 4:00 UTC (permalink / raw)
I want to use a crontab command to write daily archives to files having
the dates embedded in the filenames. A FAQ showed me how create such
files at the command prompt, as for example, 'touch home.total.`date
'+%m_%d_%y'`.pax' creates the file 'home.total.09_26_99.pax'. I cannot
get this same command to work in a crontab. The crontab itself is OK,
because 'touch filename' works. What am I doing wrong? I'm running
Tru64 UNIX 4.0E. Thanks!
Steve Stoddard
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: crontab: how to put date in archive filename?
1999-09-26 4:00 crontab: how to put date in archive filename? Steve Stoddard
@ 1999-09-27 4:00 ` Emile van Bergen
1999-09-27 4:00 ` Paul A Sand
1999-09-28 4:00 ` Steve Stoddard
2 siblings, 0 replies; 4+ messages in thread
From: Emile van Bergen @ 1999-09-27 4:00 UTC (permalink / raw)
On Sun, 26 Sep 1999, Steve Stoddard wrote:
> I want to use a crontab command to write daily archives to files having
> the dates embedded in the filenames. A FAQ showed me how create such
> files at the command prompt, as for example, 'touch home.total.`date
> '+%m_%d_%y'`.pax' creates the file 'home.total.09_26_99.pax'. I cannot
> get this same command to work in a crontab. The crontab itself is OK,
> because 'touch filename' works. What am I doing wrong? I'm running
> Tru64 UNIX 4.0E. Thanks!
I'm almost certain the problem comes from the fact that 'date' can't be
found due to its directory missing from the PATH environment variable
when running from cron. (Cron doesn't execute any of /etc/profile or
$HOME/.profile before running your command).
Specify the full path to 'date' instead and you should be all set.
--
M.vr.gr. / Best regards,
Emile van Bergen (e-mail address: emile@n293.ede.telekabel.euronet.nl)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: crontab: how to put date in archive filename?
1999-09-26 4:00 crontab: how to put date in archive filename? Steve Stoddard
1999-09-27 4:00 ` Emile van Bergen
@ 1999-09-27 4:00 ` Paul A Sand
1999-09-28 4:00 ` Steve Stoddard
2 siblings, 0 replies; 4+ messages in thread
From: Paul A Sand @ 1999-09-27 4:00 UTC (permalink / raw)
Steve Stoddard <sstod@midwest.net> writes:
>I want to use a crontab command to write daily archives to files having
>the dates embedded in the filenames. A FAQ showed me how create such
>files at the command prompt, as for example, 'touch home.total.`date
>'+%m_%d_%y'`.pax' creates the file 'home.total.09_26_99.pax'. I cannot
>get this same command to work in a crontab. The crontab itself is OK,
>because 'touch filename' works. What am I doing wrong? I'm running
>Tru64 UNIX 4.0E. Thanks!
You need to put backslashes in front of the percent signs, or double
quote them. This behavior is documented on the crontab(1) man page.
--
-- Paul A. Sand | The Springsteen Disclaimer:
-- University of New Hampshire | I ain't here on business, baby;
-- pas@unh.edu | I'm only here for fun.
-- http://pubpages.unh.edu/~pas |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: crontab: how to put date in archive filename?
1999-09-26 4:00 crontab: how to put date in archive filename? Steve Stoddard
1999-09-27 4:00 ` Emile van Bergen
1999-09-27 4:00 ` Paul A Sand
@ 1999-09-28 4:00 ` Steve Stoddard
2 siblings, 0 replies; 4+ messages in thread
From: Steve Stoddard @ 1999-09-28 4:00 UTC (permalink / raw)
Found the answer. Both replies were partially correct but there was an
additional problem: the backticks were OK but the inside single quotes in
the command string, while OK in a terminal, were messing it up in the
crontab even after adding the backslashes. The correct crontab command
for tcsh and bash is:
touch home.total.`/usr/bin/date +\%m_\%d_\%y`.pax
S. Stoddard
Steve Stoddard wrote:
> I want to use a crontab command to write daily archives to files having
> the dates embedded in the filenames. A FAQ showed me how create such
> files at the command prompt, as for example, 'touch home.total.`date
> '+%m_%d_%y'`.pax' creates the file 'home.total.09_26_99.pax'. I cannot
> get this same command to work in a crontab. The crontab itself is OK,
> because 'touch filename' works. What am I doing wrong? I'm running
> Tru64 UNIX 4.0E. Thanks!
>
> Steve Stoddard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-09-28 4:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-09-26 4:00 crontab: how to put date in archive filename? Steve Stoddard
1999-09-27 4:00 ` Emile van Bergen
1999-09-27 4:00 ` Paul A Sand
1999-09-28 4:00 ` Steve Stoddard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox