From owner-freebsd-questions@FreeBSD.ORG Mon Jun 13 22:03:01 2011 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E11E8106566C for ; Mon, 13 Jun 2011 22:03:01 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id A43588FC18 for ; Mon, 13 Jun 2011 22:03:01 +0000 (UTC) Received: from r55.edvax.de (port-92-195-180-180.dynamic.qsc.de [92.195.180.180]) by mx02.qsc.de (Postfix) with ESMTP id 0686B1D918; Tue, 14 Jun 2011 00:02:59 +0200 (CEST) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id p5DM2w8r002526; Tue, 14 Jun 2011 00:02:59 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Tue, 14 Jun 2011 00:02:58 +0200 From: Polytropon To: Kurt Buff Message-Id: <20110614000258.c5cb84f3.freebsd@edvax.de> In-Reply-To: References: Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Questions Subject: Re: Probably working too hard for this cron question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2011 22:03:02 -0000 On Mon, 13 Jun 2011 14:44:29 -0700, Kurt Buff wrote: > Per the handbook, I added > > SHELL=/bin/sh > > to crontab, and I also added > > #!/bin/sh > > as the first line in the script > > But, while a file is being created, it's just > > /root/-external1.txt > > not > > /root/2011-06-13-external1.txt Just a wild guess: How about adding {} to the variable identifiers? There are some restrictions in how far a character following the variable name will be treated as a "stop sign", e. g. variable x, literal y, and you have $xy which won't work, but $x_y may work, so you use ${x}y to make sure the name is properly scoped. Refering to your original script: #!/bin/sh dt=`/bin/date "+%Y-%m-%d"` /bin/date > /root/${dt}-external1.txt /usr/local/bin/curl -K /root/urls.txt >> /root/${dt}-external1.txt /bin/date >> /root/${dt}-external1.txt Could you try that? As you mentioned ${dt} would be empty upon cron execution, but not when run interactively, I would guess that the execution of a value assignment keeps its value just as long as it is within the same shell environment (unless you set an environmental variable via export command). If the script would be executed by cron with one shell call per line... but I think that it isn't done that way as it sounds too wrong... -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...