tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: Crontab and commands parameters
@ 1999-03-16  8:22 maurerf
  0 siblings, 0 replies; only message in thread
From: maurerf @ 1999-03-16  8:22 UTC (permalink / raw)
  To: tru64-unix-managers

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
__________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-03-16  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-03-16  8:22 SUMMARY: Crontab and commands parameters maurerf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox