From: maurerf () post ! ch
To: tru64-unix-managers
Subject: SUMMARY: Crontab and commands parameters
Date: Tue, 16 Mar 1999 08:22:38 +0000 [thread overview]
Message-ID: <96079038515699.tru64-unix-managers.marc@archive.invalid> (raw)
A big thanks to all the following persons who were answering so quickly:
Thomas Leitner
Dr Tom Blinn
Paul A Sand
Antony Patchett
Sean O'Connell
Claude Charest
H. Blakely Williford
Georg Tasman
Walter North
Jim Belonis
James Sainsbury
Michael Bradford
I don't feel alone!
The original question was:
I'd like to enter the following entry in my crontab:
## EDI secondary archiving
1 0 * * 1 /usr/sbin/decedi_arch -v -b `/sbin/date +%d%m%Y` -o
/data2/decedi/arch/`/sbin/date +%Y%m%d`.tar -c eit > /dev/null
But this is generating an error message due to an invalid parameter.
Solution:
I received 2 kinds of answers, the one were to sugest the creation of a
separate shell script, and then call this script in Crontab. The major
advantage of this method is that the result of shell commands directly in
Crontab may not be predictable. In this case it would looks like sugested by
Sean O'Connell:
/usr/sbin/decedi_arch.sh:
#!/bin/sh
TODAY1=`/sbin/date +%d%m%Y`
TODAY2=`/sbin/date +%Y%m%d`
ARCH=/data2/decedi/arch
/usr/sbin/decedi_arch -v -b ${TODAY1} -o ${ARCH}/${TODAY2}.tar -c eit
crontab entry:
## EDI secondary archiving
1 0 * * 1 /usr/sbin/decedi_arch.sh > /dev/null
I also received an other suggestion from Paul A. Sand. Somewhere in the
Crontab manpages it is explained that a % in the sixth field will treat the
preceeding characters as a command, and makes all that follows it available
to standard input, unless you escape the percent sign (\%) or double quote
it ("%").
This my prefered method, because of the simplicity (and readability):
1 0 * * 1 /usr/sbin/decedi_arch -v -b `/sbin/date +\%d\%m\%Y` -o
/data2/decedi/arch/`/sbin/date +\%Y\%m\%d`.tar -c eit > /dev/null
__________________________________________________
Felix Maurer
Die Schweizerische Post Tel: +41-31-338 98 49
Informatik POST Fax: +41-31-338 98 80
Messaging Management
Webergutstrasse 12 Mailto:maurerf@post.ch
CH-3030 Bern http://www.post.ch
__________________________________________________
reply other threads:[~1999-03-16 8:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox